1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use ChildNode.remove instead of ChildNode.ParentNode.removeChild in a couple of places (bug 1334831, issue 8008)

Re: [bug 1334831](https://bugzilla.mozilla.org/show_bug.cgi?id=1334831) and issue 8008.

Note that according to the specification, see https://dom.spec.whatwg.org/#interface-childnode, the `remove` method shouldn't throw.
This is also consistent with e.g. the Firefox implementation, see http://searchfox.org/mozilla-central/rev/d3307f19d5dac31d7d36fc206b00b686de82eee4/dom/base/nsINode.cpp#1852.

Obviously this isn't supported in IE (because that would be too easy), however we can easily polyfill it to avoid having to WONTFIX the bug/issue.
This commit is contained in:
Jonas Jenwald 2017-02-10 14:19:26 +01:00
parent ba81b37b43
commit 63f13773e7
3 changed files with 19 additions and 10 deletions

View file

@ -59,13 +59,10 @@ FontLoader.prototype = {
},
clear: function fontLoaderClear() {
var styleElement = this.styleElement;
if (styleElement) {
if (styleElement.parentNode) {
// Prevent "TypeError: styleElement.parentNode is null" during testing.
styleElement.parentNode.removeChild(styleElement);
}
styleElement = this.styleElement = null;
if (this.styleElement) {
// Note: ChildNode.remove doesn't throw if the parentNode is undefined.
this.styleElement.remove();
this.styleElement = null;
}
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
this.nativeFontFaces.forEach(function(nativeFontFace) {