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:
parent
ba81b37b43
commit
63f13773e7
@ -59,13 +59,10 @@ FontLoader.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
clear: function fontLoaderClear() {
|
clear: function fontLoaderClear() {
|
||||||
var styleElement = this.styleElement;
|
if (this.styleElement) {
|
||||||
if (styleElement) {
|
// Note: ChildNode.remove doesn't throw if the parentNode is undefined.
|
||||||
if (styleElement.parentNode) {
|
this.styleElement.remove();
|
||||||
// Prevent "TypeError: styleElement.parentNode is null" during testing.
|
this.styleElement = null;
|
||||||
styleElement.parentNode.removeChild(styleElement);
|
|
||||||
}
|
|
||||||
styleElement = this.styleElement = null;
|
|
||||||
}
|
}
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
|
||||||
this.nativeFontFaces.forEach(function(nativeFontFace) {
|
this.nativeFontFaces.forEach(function(nativeFontFace) {
|
||||||
|
@ -646,4 +646,17 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Provides support for ChildNode.remove in legacy browsers.
|
||||||
|
// Support: IE.
|
||||||
|
(function checkChildNodeRemove() {
|
||||||
|
if (typeof Element.prototype.remove !== 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Element.prototype.remove = function () {
|
||||||
|
if (this.parentNode) {
|
||||||
|
this.parentNode.removeChild(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
}).call((typeof window === 'undefined') ? this : window);
|
}).call((typeof window === 'undefined') ? this : window);
|
||||||
|
@ -184,9 +184,8 @@
|
|||||||
this.element.removeEventListener('scroll', this._endPan, true);
|
this.element.removeEventListener('scroll', this._endPan, true);
|
||||||
this.document.removeEventListener('mousemove', this._onmousemove, true);
|
this.document.removeEventListener('mousemove', this._onmousemove, true);
|
||||||
this.document.removeEventListener('mouseup', this._endPan, true);
|
this.document.removeEventListener('mouseup', this._endPan, true);
|
||||||
if (this.overlay.parentNode) {
|
// Note: ChildNode.remove doesn't throw if the parentNode is undefined.
|
||||||
this.overlay.parentNode.removeChild(this.overlay);
|
this.overlay.remove();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user