Merge pull request #8056 from Snuffleupagus/ChildNode.remove
Use `ChildNode.remove` instead of `ChildNode.ParentNode.removeChild` in a couple of places (bug 1334831, issue 8008)
This commit is contained in:
commit
466760efca
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -184,9 +184,8 @@
|
||||
this.element.removeEventListener('scroll', this._endPan, true);
|
||||
this.document.removeEventListener('mousemove', this._onmousemove, true);
|
||||
this.document.removeEventListener('mouseup', this._endPan, true);
|
||||
if (this.overlay.parentNode) {
|
||||
this.overlay.parentNode.removeChild(this.overlay);
|
||||
}
|
||||
// Note: ChildNode.remove doesn't throw if the parentNode is undefined.
|
||||
this.overlay.remove();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user