15 lines
380 B
JavaScript
15 lines
380 B
JavaScript
export function skipToNextNonDescendant(treeWalker) {
|
|
// Try to go to next sibling
|
|
if (treeWalker.nextSibling()) {
|
|
return true;
|
|
}
|
|
// No sibling, go up to parent and try to find ancestor's sibling
|
|
while (treeWalker.parentNode()) {
|
|
if (treeWalker.nextSibling()) {
|
|
return true;
|
|
}
|
|
}
|
|
// No more nodes
|
|
return false;
|
|
}
|