From 781273e91d4d44bdd9d43e4274fd781765772b19 Mon Sep 17 00:00:00 2001 From: tobspr Date: Thu, 16 Jun 2022 12:10:09 +0200 Subject: [PATCH] Add html element remove polyfill --- src/js/core/polyfills.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/js/core/polyfills.js b/src/js/core/polyfills.js index 8f6f8ffe..52c17911 100644 --- a/src/js/core/polyfills.js +++ b/src/js/core/polyfills.js @@ -83,10 +83,30 @@ function objectPolyfills() { } } +function domPolyfills() { + // from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md + (function (arr) { + arr.forEach(function (item) { + if (item.hasOwnProperty("remove")) { + return; + } + Object.defineProperty(item, "remove", { + configurable: true, + enumerable: true, + writable: true, + value: function remove() { + this.parentNode.removeChild(this); + }, + }); + }); + })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); +} + function initPolyfills() { mathPolyfills(); stringPolyfills(); objectPolyfills(); + domPolyfills(); } function initExtensions() {