From 1c160083f2aa333aa108b3a048a7da9b8fc8e92a Mon Sep 17 00:00:00 2001 From: Barry Rowe Date: Wed, 18 May 2016 10:19:11 -0400 Subject: [PATCH] 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. --- ionic/util/dom.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ionic/util/dom.ts b/ionic/util/dom.ts index d8dae8e354..6684600486 100644 --- a/ionic/util/dom.ts +++ b/ionic/util/dom.ts @@ -25,7 +25,9 @@ })(); // use native raf rather than the zone wrapped one -export const nativeRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')])['bind'](window); +let originalRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')]); +// if the originalRaf from the Zone symbol is not available, we need to provide the polyfilled version +export const nativeRaf = originalRaf !== undefined ? originalRaf['bind'](window) : window.requestAnimationFrame.bind(window); // zone wrapped raf export const raf = window.requestAnimationFrame.bind(window);