From aff7a4e0a5bf1a8fde2b3e32339a402e8ed15fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Sat, 14 Jun 2025 04:02:47 +0300 Subject: [PATCH] Remove DOM remove() polyfills Remove polyfill functions for Element, CharacterData and DocumentType classes, as these methods are all Baseline Widely Available. Also get rid of redundant IIFE for the Math "polyfills". --- src/js/core/polyfills.js | 38 -------------------------------------- src/js/core/polyfills.ts | 9 +++++++++ 2 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 src/js/core/polyfills.js create mode 100644 src/js/core/polyfills.ts diff --git a/src/js/core/polyfills.js b/src/js/core/polyfills.js deleted file mode 100644 index 5f979c43..00000000 --- a/src/js/core/polyfills.js +++ /dev/null @@ -1,38 +0,0 @@ -function mathPolyfills() { - // Converts from degrees to radians. - Math.radians = function (degrees) { - return (degrees * Math.PI) / 180.0; - }; - - // Converts from radians to degrees. - Math.degrees = function (radians) { - return (radians * 180.0) / Math.PI; - }; -} - -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(); - domPolyfills(); -} - -// Other polyfills -initPolyfills(); diff --git a/src/js/core/polyfills.ts b/src/js/core/polyfills.ts new file mode 100644 index 00000000..0467e50f --- /dev/null +++ b/src/js/core/polyfills.ts @@ -0,0 +1,9 @@ +// Converts from degrees to radians. +Math.radians = function (degrees: number): number { + return (degrees * Math.PI) / 180.0; +}; + +// Converts from radians to degrees. +Math.degrees = function (radians: number): number { + return (radians * 180.0) / Math.PI; +};