1 | export function applyPolyfills() {
|
2 | var promises = [];
|
3 | if (typeof window !== 'undefined') {
|
4 | var win = window;
|
5 |
|
6 | if (!win.customElements ||
|
7 | (win.Element && (!win.Element.prototype.closest || !win.Element.prototype.matches || !win.Element.prototype.remove || !win.Element.prototype.getRootNode))) {
|
8 | promises.push(import( './dom.js'));
|
9 | }
|
10 |
|
11 | var checkIfURLIsSupported = function() {
|
12 | try {
|
13 | var u = new URL('b', 'http://a');
|
14 | u.pathname = 'c%20d';
|
15 | return (u.href === 'http://a/c%20d') && u.searchParams;
|
16 | } catch (e) {
|
17 | return false;
|
18 | }
|
19 | };
|
20 |
|
21 | if (
|
22 | 'function' !== typeof Object.assign || !Object.entries ||
|
23 | !Array.prototype.find || !Array.prototype.includes ||
|
24 | !String.prototype.startsWith || !String.prototype.endsWith ||
|
25 | (win.NodeList && !win.NodeList.prototype.forEach) ||
|
26 | !win.fetch ||
|
27 | !checkIfURLIsSupported() ||
|
28 | typeof WeakMap == 'undefined'
|
29 | ) {
|
30 | promises.push(import( './core-js.js'));
|
31 | }
|
32 | }
|
33 | return Promise.all(promises);
|
34 | }
|