Prevent errors in various methods in SimpleDOMNode when the childNodes property is not defined (issue 10395)

Given that the issue, as filed, is incomplete since no PDF file was provided for debugging, this patch is really the best that we can do here. *Please note:* This patch will *not* enable the Metadata to be successfully parsed, but it should at least prevent the errors.
This commit is contained in:
Jonas Jenwald 2018-12-31 12:57:37 +01:00
parent 85363f4566
commit d371d23382

View File

@ -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() {