mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixed node.previousSibling and node.nextSibling
This commit is contained in:
parent
b90fe7740f
commit
2ae20ae431
@ -118,6 +118,8 @@ class ArrayContainer extends Container {
|
||||
}
|
||||
var array = this.array;
|
||||
|
||||
|
||||
|
||||
for (var i=0; i<array.length; i++) {
|
||||
var curNode = array[i];
|
||||
if (curNode.container !== this) {
|
||||
@ -125,7 +127,9 @@ class ArrayContainer extends Container {
|
||||
}
|
||||
|
||||
if (curNode === node) {
|
||||
return i-1 >= 0 ? array[i+1] : undefined;
|
||||
console.log("ARRAY:", i-1 >= 0 ? array[i-1] : undefined);
|
||||
|
||||
return i-1 >= 0 ? array[i-1] : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class Node {
|
||||
var container = this.container;
|
||||
|
||||
if (container) {
|
||||
container.getPreviousSibling(this);
|
||||
return container.getPreviousSibling(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class Node {
|
||||
var container = this.container;
|
||||
|
||||
if (container) {
|
||||
container.getNextSibling(this);
|
||||
return container.getNextSibling(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<div><a>A</a><span></span><b>B</b></div>
|
||||
@ -0,0 +1,5 @@
|
||||
{
|
||||
"<span>": {
|
||||
"transformer": "./span-transformer.js"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
var expect = require('chai').expect;
|
||||
module.exports = function(node, context) {
|
||||
var previousSibling = node.previousSibling;
|
||||
var nextSibling = node.nextSibling;
|
||||
|
||||
expect(previousSibling).to.be.an('object');
|
||||
expect(nextSibling).to.be.an('object');
|
||||
|
||||
expect(previousSibling.tagName).to.equal('a');
|
||||
expect(nextSibling.tagName).to.equal('b');
|
||||
|
||||
previousSibling.appendChild(context.builder.text(context.builder.literal('A')));
|
||||
nextSibling.appendChild(context.builder.text(context.builder.literal('B')));
|
||||
};
|
||||
@ -0,0 +1 @@
|
||||
<div><a></a><span></span><b></b></div>
|
||||
Loading…
x
Reference in New Issue
Block a user