1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00

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".
This commit is contained in:
Даниїл Григор'єв 2025-06-14 04:02:47 +03:00
parent eb7564b1a9
commit aff7a4e0a5
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D
2 changed files with 9 additions and 38 deletions

View File

@ -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();

9
src/js/core/polyfills.ts Normal file
View File

@ -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;
};