Skip to content

Commit 9522ade

Browse files
committed
refactor: polyfills cleanup
1 parent f6a710f commit 9522ade

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'react-app-polyfill/ie11'; // For IE 11 support
22
import 'react-app-polyfill/stable';
3+
import 'core-js';
34
import './polyfill'
45
import React from 'react';
56
import ReactDOM from 'react-dom';
@@ -16,7 +17,7 @@ React.icons = icons
1617
ReactDOM.render(
1718
<Provider store={store}>
1819
<App/>
19-
</Provider>,
20+
</Provider>,
2021
document.getElementById('root')
2122
);
2223

src/polyfill.js

+36-20
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
/*
22
* required polyfills
33
*/
4-
import "core-js";
5-
import 'core-js/features/set/map';
6-
import 'core-js/features/map';
74

85
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
9-
// import 'core-js/es6/symbol'
10-
// import 'core-js/es6/object'
11-
// import 'core-js/es6/function'
12-
// import 'core-js/es6/parse-int'
13-
// import 'core-js/es6/parse-float'
14-
// import 'core-js/es6/number'
15-
// import 'core-js/es6/math'
16-
// import 'core-js/es6/string'
17-
// import 'core-js/es6/date'
18-
// import 'core-js/es6/array'
19-
// import 'core-js/es6/regexp'
20-
// import 'core-js/es6/map'
21-
// import 'core-js/es6/weak-map'
22-
// import 'core-js/es6/set'
23-
// import 'core-js/es7/object'
6+
// import "core-js";
7+
// import 'core-js/features/symbol'
8+
// import 'core-js/features/object'
9+
// import 'core-js/features/function'
10+
// import 'core-js/features/parse-int'
11+
// import 'core-js/features/parse-float'
12+
// import 'core-js/features/number'
13+
// import 'core-js/features/math'
14+
// import 'core-js/features/string'
15+
// import 'core-js/features/date'
16+
// import 'core-js/features/array'
17+
// import 'core-js/features/regexp'
18+
// import 'core-js/features/map'
19+
// import 'core-js/features/weak-map'
20+
// import 'core-js/features/set'
21+
// import 'core-js/features/set/map';
2422

2523
/** IE10 and IE11 requires the following for the Reflect API. */
26-
// import 'core-js/es6/reflect'
24+
// import 'core-js/features/reflect';
2725

2826
/** Evergreen browsers require these. **/
2927
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
30-
// import 'core-js/es7/reflect'
28+
// import 'core-js/features/reflect'
3129

3230
// CustomEvent() constructor functionality in IE9, IE10, IE11
3331
(function () {
@@ -45,3 +43,21 @@ import 'core-js/features/map';
4543

4644
window.CustomEvent = CustomEvent
4745
})()
46+
47+
if (!Element.prototype.matches) {
48+
Element.prototype.matches =
49+
Element.prototype.msMatchesSelector ||
50+
Element.prototype.webkitMatchesSelector;
51+
}
52+
53+
if (!Element.prototype.closest) {
54+
Element.prototype.closest = function(s) {
55+
var el = this;
56+
57+
do {
58+
if (Element.prototype.matches.call(el, s)) return el;
59+
el = el.parentElement || el.parentNode;
60+
} while (el !== null && el.nodeType === 1);
61+
return null;
62+
};
63+
}

0 commit comments

Comments
 (0)