-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5123608
commit 755ff0d
Showing
2 changed files
with
31 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
export function applyPolyfills() { | ||
var win = window; | ||
if (typeof window !== 'undefined') { | ||
var win = window; | ||
|
||
var promises = []; | ||
var promises = []; | ||
|
||
if (!win.customElements || (win.Element && (!win.Element.prototype.closest || !win.Element.prototype.matches || !win.Element.prototype.remove))) { | ||
promises.push(import('./dom.js')); | ||
} | ||
if (!win.customElements || (win.Element && (!win.Element.prototype.closest || !win.Element.prototype.matches || !win.Element.prototype.remove))) { | ||
promises.push(import('./dom.js')); | ||
} | ||
|
||
function checkIfURLIsSupported() { | ||
try { | ||
var u = new URL('b', 'http://a'); | ||
u.pathname = 'c%20d'; | ||
return (u.href === 'http://a/c%20d') && u.searchParams; | ||
} catch(e) { | ||
return false; | ||
function checkIfURLIsSupported() { | ||
try { | ||
var u = new URL('b', 'http://a'); | ||
u.pathname = 'c%20d'; | ||
return (u.href === 'http://a/c%20d') && u.searchParams; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
if ( | ||
'function' !== typeof Object.assign || !Object.entries || | ||
!Array.prototype.find || !Array.prototype.includes || | ||
!String.prototype.startsWith || !String.prototype.endsWith || | ||
(win.NodeList && !win.NodeList.prototype.forEach) || | ||
!win.fetch || | ||
!checkIfURLIsSupported() || | ||
typeof WeakMap == 'undefined' | ||
) { | ||
promises.push(import('./core-js.js')); | ||
if ( | ||
'function' !== typeof Object.assign || !Object.entries || | ||
!Array.prototype.find || !Array.prototype.includes || | ||
!String.prototype.startsWith || !String.prototype.endsWith || | ||
(win.NodeList && !win.NodeList.prototype.forEach) || | ||
!win.fetch || | ||
!checkIfURLIsSupported() || | ||
typeof WeakMap == 'undefined' | ||
) { | ||
promises.push(import('./core-js.js')); | ||
} | ||
return Promise.all(promises); | ||
} | ||
return Promise.all(promises); | ||
return Promise.resolve(); | ||
} |