|
1 | | -// Polyfills for older browsers, most notably IE11. |
2 | | -// |
3 | | -// Use polyfills-loader.js before the Patternslib bundle to conditionally load |
4 | | -// the polyfills for Internet Explorer: |
5 | | -// |
6 | | -// <script src="polyfills-loader.js" type="text/javascript"></script> |
7 | | - |
8 | | -// Core JS features |
9 | | -// You can also import individual core-js features: |
10 | | -// import "core-js/stable/object/assign"; |
11 | | -// But we're importing them all: |
12 | | -import "core-js/stable"; |
13 | | - |
14 | | -// Web APIs |
15 | | -import "intersection-observer"; |
16 | | -import "promise-polyfill/src/polyfill"; |
17 | | -import "url-polyfill"; |
18 | | -import "whatwg-fetch"; |
19 | | -import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer"; |
20 | | - |
21 | | -if ("ResizeObserver" in window === false) { |
22 | | - window.ResizeObserver = ResizeObserverPolyfill; |
23 | | -} |
24 | | - |
25 | | -// Node.closest polyfill |
26 | | -// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill |
27 | | -if (!Element.prototype.matches) { |
28 | | - Element.prototype.matches = |
29 | | - Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; |
30 | | -} |
31 | | -if (!Element.prototype.closest) { |
32 | | - Element.prototype.closest = function (s) { |
33 | | - var el = this; |
34 | | - do { |
35 | | - if (Element.prototype.matches.call(el, s)) return el; |
36 | | - el = el.parentElement || el.parentNode; |
37 | | - } while (el !== null && el.nodeType === 1); |
38 | | - return null; |
39 | | - }; |
40 | | -} |
41 | | -// END Node.closest polyfill |
42 | | - |
43 | | -if (!document.currentScript) { |
44 | | - var scripts = document.getElementsByTagName("script"); |
45 | | - document.currentScript = scripts.length && scripts[scripts.length - 1]; |
46 | | -} |
47 | | - |
48 | | -// Node.remove polyfill |
49 | | -// From: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#polyfill |
50 | | -// From: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md |
51 | | -(function (arr) { |
52 | | - arr.forEach(function (item) { |
53 | | - // eslint-disable-next-line no-prototype-builtins |
54 | | - if (item.hasOwnProperty("remove")) { |
55 | | - return; |
56 | | - } |
57 | | - Object.defineProperty(item, "remove", { |
58 | | - configurable: true, |
59 | | - enumerable: true, |
60 | | - writable: true, |
61 | | - value: function remove() { |
62 | | - this.parentNode.removeChild(this); |
63 | | - }, |
64 | | - }); |
65 | | - }); |
66 | | -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); |
67 | | -// END Node.remove polyfill |
68 | | - |
69 | | -// input.labels polyfill |
0 commit comments