Merge pull request #10398 from Snuffleupagus/issue-10395

Prevent errors in various methods in `SimpleDOMNode` when the `childNodes` property is not defined (issue 10395)
This commit is contained in:
Tim van der Meij 2019-01-01 16:22:11 +01:00 committed by GitHub
commit 1b84b2ed60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,12 +278,16 @@ class SimpleDOMNode {
} }
get firstChild() { get firstChild() {
return this.childNodes[0]; return this.childNodes && this.childNodes[0];
} }
get nextSibling() { get nextSibling() {
let index = this.parentNode.childNodes.indexOf(this); const childNodes = this.parentNode.childNodes;
return this.parentNode.childNodes[index + 1]; if (!childNodes) {
return undefined;
}
const index = childNodes.indexOf(this);
return childNodes[index + 1];
} }
get textContent() { get textContent() {