Skip to content

Commit

Permalink
Merge pull request #10398 from Snuffleupagus/issue-10395
Browse files Browse the repository at this point in the history
Prevent errors in various methods in `SimpleDOMNode` when the `childNodes` property is not defined (issue 10395)
  • Loading branch information
timvandermeij authored Jan 1, 2019
2 parents d8f201e + d371d23 commit 1b84b2e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/display/xml_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,16 @@ class SimpleDOMNode {
}

get firstChild() {
return this.childNodes[0];
return this.childNodes && this.childNodes[0];
}

get nextSibling() {
let index = this.parentNode.childNodes.indexOf(this);
return this.parentNode.childNodes[index + 1];
const childNodes = this.parentNode.childNodes;
if (!childNodes) {
return undefined;
}
const index = childNodes.indexOf(this);
return childNodes[index + 1];
}

get textContent() {
Expand Down

0 comments on commit 1b84b2e

Please sign in to comment.