Skip to content

Commit 1c16008

Browse files
Barryroweadamdbradley
authored andcommitted
fix(raf): test for undefined raf
When in a headless environment RAF may not be defined so we need to return the polyfilled version rather than letting the undefined function be called.
1 parent daa4ccc commit 1c16008

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ionic/util/dom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
})();
2626

2727
// use native raf rather than the zone wrapped one
28-
export const nativeRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')])['bind'](window);
28+
let originalRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')]);
29+
// if the originalRaf from the Zone symbol is not available, we need to provide the polyfilled version
30+
export const nativeRaf = originalRaf !== undefined ? originalRaf['bind'](window) : window.requestAnimationFrame.bind(window);
2931

3032
// zone wrapped raf
3133
export const raf = window.requestAnimationFrame.bind(window);

0 commit comments

Comments
 (0)