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.
This commit is contained in:
Barry Rowe
2016-05-18 10:19:11 -04:00
committed by Adam Bradley
parent daa4ccc30c
commit 1c160083f2

View File

@ -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);