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:
parent
eb7564b1a9
commit
aff7a4e0a5
@ -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
9
src/js/core/polyfills.ts
Normal 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;
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user