mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-08 16:00:06 -05:00
TreeWalker must not try to access parent of root node
This commit is contained in:
parent
183091e4e1
commit
c83688b630
1 changed files with 8 additions and 10 deletions
|
@ -76,15 +76,12 @@ TreeWalker.prototype.nextNode = function () {
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
node = current.firstChild;
|
node = current.firstChild;
|
||||||
while ( !node && current ) {
|
while ( !node && current ) {
|
||||||
node = current.nextSibling;
|
|
||||||
if ( !node ) {
|
|
||||||
current = current.parentNode;
|
|
||||||
if ( current === root ) {
|
if ( current === root ) {
|
||||||
return null;
|
break;
|
||||||
}
|
}
|
||||||
|
node = current.nextSibling;
|
||||||
|
if ( !node ) { current = current.parentNode; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( !node ) {
|
if ( !node ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +90,6 @@ TreeWalker.prototype.nextNode = function () {
|
||||||
this.currentNode = node;
|
this.currentNode = node;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = node;
|
current = node;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -105,7 +101,7 @@ TreeWalker.prototype.previousNode = function () {
|
||||||
filter = this.filter,
|
filter = this.filter,
|
||||||
node;
|
node;
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
if ( node === root ) {
|
if ( current === root ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
node = current.previousSibling;
|
node = current.previousSibling;
|
||||||
|
@ -116,12 +112,14 @@ TreeWalker.prototype.previousNode = function () {
|
||||||
} else {
|
} else {
|
||||||
node = current.parentNode;
|
node = current.parentNode;
|
||||||
}
|
}
|
||||||
|
if ( !node ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if ( ( typeToBitArray[ node.nodeType ] & nodeType ) &&
|
if ( ( typeToBitArray[ node.nodeType ] & nodeType ) &&
|
||||||
filter( node ) === FILTER_ACCEPT ) {
|
filter( node ) === FILTER_ACCEPT ) {
|
||||||
this.currentNode = node;
|
this.currentNode = node;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = node;
|
current = node;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue