Skip to content

Commit

Permalink
Remove various polyfills (#5448)
Browse files Browse the repository at this point in the history
* Remove Promise, CustomEvent, Performance.now and String.startsWith polyfills

* Remove @ungap/custom-elements polyfill

* Replace object-assign ponyfill with Object.assign

---------

Co-authored-by: Noeri Huisman <[email protected]>
  • Loading branch information
mrxz and mrxz authored Feb 7, 2024
1 parent 33c9414 commit 5d3f449
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 50 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@
"vendor/**/*"
],
"dependencies": {
"@ungap/custom-elements": "^1.1.0",
"buffer": "^6.0.3",
"custom-event-polyfill": "^1.0.6",
"debug": "ngokevin/debug#noTimestamp",
"deep-assign": "^2.0.0",
"load-bmfont": "^1.2.3",
"object-assign": "^4.0.1",
"present": "0.0.6",
"promise-polyfill": "^3.1.0",
"super-animejs": "^3.1.0",
"super-three": "0.161.0",
"three-bmfont-text": "dmarcos/three-bmfont-text#eed4878795be9b3e38cf6aec6b903f56acd1f695",
Expand Down
15 changes: 0 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Polyfill `Promise`.
window.Promise = window.Promise || require('promise-polyfill');

require('@ungap/custom-elements');

// WebVR polyfill
// Check before the polyfill runs.
window.hasNativeWebVRImplementation = !!window.navigator.getVRDisplays ||
Expand All @@ -27,14 +22,6 @@ if (!window.hasNativeWebXRImplementation && !window.hasNativeWebVRImplementation

var utils = require('./utils/');
var debug = utils.debug;

if (utils.isIE11) {
// Polyfill `CustomEvent`.
require('custom-event-polyfill');
// Polyfill String.startsWith.
require('../vendor/starts-with-polyfill');
}

var error = debug('A-Frame:error');
var warn = debug('A-Frame:warn');

Expand All @@ -54,8 +41,6 @@ if (!window.cordova && window.location.protocol === 'file:') {
'https://aframe.io/docs/1.4.0/introduction/installation.html#use-a-local-server.');
}

require('present'); // Polyfill `performance.now()`.

// CSS.
if (utils.device.isBrowserEnvironment) {
require('./style/aframe.css');
Expand Down
3 changes: 1 addition & 2 deletions src/utils/coordinates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global THREE */
var debug = require('./debug');
var extend = require('object-assign');

var warn = debug('utils:coordinates:warn');

Expand Down Expand Up @@ -45,7 +44,7 @@ function parse (value, defaultVec) {
}

if (value === null || value === undefined) {
return typeof defaultVec === 'object' ? extend({}, defaultVec) : defaultVec;
return typeof defaultVec === 'object' ? Object.assign({}, defaultVec) : defaultVec;
}

coordinate = value.trim().split(whitespaceRegex);
Expand Down
3 changes: 1 addition & 2 deletions src/utils/debug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var debugLib = require('debug');
var extend = require('object-assign');

var settings = {
colors: {
Expand All @@ -22,7 +21,7 @@ var debug = function (namespace) {

return d;
};
extend(debug, debugLib);
Object.assign(debug, debugLib);

/**
* Returns the type of the namespace (e.g., `error`, `warn`).
Expand Down
4 changes: 1 addition & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var debug = require('./debug');
var deepAssign = require('deep-assign');
var device = require('./device');
var objectAssign = require('object-assign');
var objectPool = require('./object-pool');

var warn = debug('utils:warn');
Expand All @@ -15,7 +14,6 @@ module.exports.debug = debug;
module.exports.device = device;
module.exports.entity = require('./entity');
module.exports.forceCanvasResizeSafariMobile = require('./forceCanvasResizeSafariMobile');
module.exports.isIE11 = require('./is-ie11');
module.exports.material = require('./material');
module.exports.objectPool = objectPool;
module.exports.split = require('./split').split;
Expand Down Expand Up @@ -159,7 +157,7 @@ module.exports.debounce = function (func, wait, immediate) {
* @param {object} dest - The object to which properties will be copied.
* @param {...object} source - The object(s) from which properties will be copied.
*/
module.exports.extend = objectAssign;
module.exports.extend = Object.assign;
module.exports.extendDeep = deepAssign;

module.exports.clone = function (obj) {
Expand Down
16 changes: 0 additions & 16 deletions src/utils/is-ie11.js

This file was deleted.

7 changes: 0 additions & 7 deletions vendor/starts-with-polyfill.js

This file was deleted.

0 comments on commit 5d3f449

Please sign in to comment.