Skip to content

Commit

Permalink
640: Fixed prev/nextSibling
Browse files Browse the repository at this point in the history
  • Loading branch information
kpalatzky committed Nov 8, 2023
1 parent 0119362 commit 6b246a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,19 @@ export class XMLNode extends XMLReference<xmlNodePtr> {
}

public prevSibling(): XMLNode|null {
return refToNodeType(this.getNativeReference().prev) as XMLNode|null;
const sibling = refToNodeType(this.getNativeReference().prev);
if (sibling === null || sibling instanceof XMLDocument) {
return null;
}
return sibling;
}

public nextSibling(): XMLNode|null {
return refToNodeType(this.getNativeReference().next) as XMLNode|null;
const sibling = refToNodeType(this.getNativeReference().next);
if (sibling === null || sibling instanceof XMLDocument) {
return null;
}
return sibling;
}

public evaluateXPath(xpath: string, namespace?: XPathNamespace): xmlXPathObjectPtr {
Expand Down

0 comments on commit 6b246a4

Please sign in to comment.