|
| 1 | +import es6promise from 'es6-promise'; |
| 2 | +import { Uint32Array } from 'typedarray'; |
| 3 | +import 'weakmap-polyfill'; |
| 4 | +import hasOwn from 'core-js-pure/actual/object/has-own'; |
| 5 | +import values from 'core-js-pure/actual/object/values'; |
| 6 | + |
| 7 | +if (!('hasOwn' in Object)) { |
| 8 | + Object.hasOwn = hasOwn; |
| 9 | +} |
| 10 | + |
| 11 | +if (!('values' in Object)) { |
| 12 | + Object.values = values; |
| 13 | +} |
| 14 | + |
| 15 | +if (!('Promise' in window)) { |
| 16 | + es6promise.polyfill(); |
| 17 | +} |
| 18 | + |
| 19 | +if (!('Uint32Array' in window)) { |
| 20 | + window.Uint32Array = Uint32Array; |
| 21 | +} |
| 22 | +if (window.Uint32Array) { |
| 23 | + // @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some |
| 24 | + if (!('some' in window.Uint32Array.prototype)) { |
| 25 | + Object.defineProperty(window.Uint32Array.prototype, 'some', { |
| 26 | + value: Array.prototype.some |
| 27 | + }); |
| 28 | + } |
| 29 | + |
| 30 | + if (!('reduce' in window.Uint32Array.prototype)) { |
| 31 | + // @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce |
| 32 | + Object.defineProperty(window.Uint32Array.prototype, 'reduce', { |
| 33 | + value: Array.prototype.reduce |
| 34 | + }); |
| 35 | + } |
| 36 | +} |
| 37 | + |
1 | 38 | /*
|
2 | 39 | These polyfills came directly from the ES Specification itself
|
3 | 40 | Contained within:
|
4 |
| - - Object.assign |
5 |
| - - Array.prototype.find |
| 41 | + - Object.assign |
| 42 | + - Array.prototype.find |
6 | 43 | */
|
7 | 44 | if (typeof Object.assign !== 'function') {
|
8 | 45 | (function () {
|
@@ -76,80 +113,6 @@ if (!Array.prototype.findIndex) {
|
76 | 113 | });
|
77 | 114 | }
|
78 | 115 |
|
79 |
| -// Spelled incorrectly intentionally (backwards compatibility). |
80 |
| -export function pollyfillElementsFromPoint() { |
81 |
| - if (document.elementsFromPoint) return document.elementsFromPoint; |
82 |
| - if (document.msElementsFromPoint) return document.msElementsFromPoint; |
83 |
| - |
84 |
| - var usePointer = (function () { |
85 |
| - var element = document.createElement('x'); |
86 |
| - element.style.cssText = 'pointer-events:auto'; |
87 |
| - return element.style.pointerEvents === 'auto'; |
88 |
| - })(); |
89 |
| - |
90 |
| - var cssProp = usePointer ? 'pointer-events' : 'visibility'; |
91 |
| - var cssDisableVal = usePointer ? 'none' : 'hidden'; |
92 |
| - |
93 |
| - var style = document.createElement('style'); |
94 |
| - style.innerHTML = usePointer |
95 |
| - ? '* { pointer-events: all }' |
96 |
| - : '* { visibility: visible }'; |
97 |
| - |
98 |
| - return function (x, y) { |
99 |
| - var current, i, d; |
100 |
| - var elements = []; |
101 |
| - var previousPointerEvents = []; |
102 |
| - |
103 |
| - // startup |
104 |
| - document.head.appendChild(style); |
105 |
| - |
106 |
| - while ( |
107 |
| - (current = document.elementFromPoint(x, y)) && |
108 |
| - elements.indexOf(current) === -1 |
109 |
| - ) { |
110 |
| - // push the element and its current style |
111 |
| - elements.push(current); |
112 |
| - |
113 |
| - previousPointerEvents.push({ |
114 |
| - value: current.style.getPropertyValue(cssProp), |
115 |
| - priority: current.style.getPropertyPriority(cssProp) |
116 |
| - }); |
117 |
| - |
118 |
| - // add "pointer-events: none", to get to the underlying element |
119 |
| - current.style.setProperty(cssProp, cssDisableVal, 'important'); |
120 |
| - } |
121 |
| - |
122 |
| - // Due to negative index, documentElement could actually not be the last, |
123 |
| - // so we'll simply move it to the end |
124 |
| - if (elements.indexOf(document.documentElement) < elements.length - 1) { |
125 |
| - elements.splice(elements.indexOf(document.documentElement), 1); |
126 |
| - elements.push(document.documentElement); |
127 |
| - } |
128 |
| - |
129 |
| - // restore the previous pointer-events values |
130 |
| - for ( |
131 |
| - i = previousPointerEvents.length; |
132 |
| - !!(d = previousPointerEvents[--i]); |
133 |
| - |
134 |
| - ) { |
135 |
| - elements[i].style.setProperty( |
136 |
| - cssProp, |
137 |
| - d.value ? d.value : '', |
138 |
| - d.priority |
139 |
| - ); |
140 |
| - } |
141 |
| - |
142 |
| - // teardown; |
143 |
| - document.head.removeChild(style); |
144 |
| - |
145 |
| - return elements; |
146 |
| - }; |
147 |
| -} |
148 |
| - |
149 |
| -if (typeof window.addEventListener === 'function') { |
150 |
| - document.elementsFromPoint = pollyfillElementsFromPoint(); |
151 |
| -} |
152 |
| - |
153 | 116 | if (!Array.prototype.includes) {
|
154 | 117 | Object.defineProperty(Array.prototype, 'includes', {
|
155 | 118 | value: function (searchElement) {
|
|
0 commit comments