Fixed node.previousSibling and node.nextSibling

This commit is contained in:
Patrick Steele-Idem 2017-02-08 23:47:10 -08:00
parent b90fe7740f
commit 2ae20ae431
6 changed files with 28 additions and 3 deletions

View File

@ -118,6 +118,8 @@ class ArrayContainer extends Container {
} }
var array = this.array; var array = this.array;
for (var i=0; i<array.length; i++) { for (var i=0; i<array.length; i++) {
var curNode = array[i]; var curNode = array[i];
if (curNode.container !== this) { if (curNode.container !== this) {
@ -125,7 +127,9 @@ class ArrayContainer extends Container {
} }
if (curNode === node) { 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;
} }
} }
} }

View File

@ -160,7 +160,7 @@ class Node {
var container = this.container; var container = this.container;
if (container) { if (container) {
container.getPreviousSibling(this); return container.getPreviousSibling(this);
} }
} }
@ -168,7 +168,7 @@ class Node {
var container = this.container; var container = this.container;
if (container) { if (container) {
container.getNextSibling(this); return container.getNextSibling(this);
} }
} }

View File

@ -0,0 +1 @@
<div><a>A</a><span></span><b>B</b></div>

View File

@ -0,0 +1,5 @@
{
"<span>": {
"transformer": "./span-transformer.js"
}
}

View File

@ -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')));
};

View File

@ -0,0 +1 @@
<div><a></a><span></span><b></b></div>