File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 1
1
import ResizeObserverPolyfill from './ResizeObserver.js' ;
2
+ import global from './shims/global.js' ;
2
3
3
4
export default ( ( ) => {
4
5
// Export existing implementation if available.
5
- if ( typeof ResizeObserver != 'undefined' ) {
6
- // eslint-disable-next-line no-undef
7
- return ResizeObserver ;
6
+ if ( typeof global . ResizeObserver != 'undefined' ) {
7
+ return global . ResizeObserver ;
8
8
}
9
9
10
10
return ResizeObserverPolyfill ;
Original file line number Diff line number Diff line change
1
+ export default ( ( ) => {
2
+ if ( typeof global != 'undefined' && global . Math === Math ) {
3
+ return global ;
4
+ }
5
+
6
+ if ( typeof self != 'undefined' && self . Math === Math ) {
7
+ return self ;
8
+ }
9
+
10
+ if ( typeof window != 'undefined' && window . Math === Math ) {
11
+ return window ;
12
+ }
13
+
14
+ // eslint-disable-next-line no-new-func
15
+ return Function ( 'return this' ) ( ) ;
16
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ import global from './global.js' ;
2
+
1
3
/**
2
4
* A shim for the requestAnimationFrame which falls back to the setTimeout if
3
5
* first one is not supported.
6
8
*/
7
9
export default ( ( ) => {
8
10
if ( typeof requestAnimationFrame === 'function' ) {
9
- return requestAnimationFrame ;
11
+ // It's required to use a bounded function because IE sometimes throws
12
+ // an "Invalid calling object" error if rAF is invoked without the global
13
+ // object on the left hand side.
14
+ return requestAnimationFrame . bind ( global ) ;
10
15
}
11
16
12
17
return callback => setTimeout ( ( ) => callback ( Date . now ( ) ) , 1000 / 60 ) ;
You can’t perform that action at this time.
0 commit comments