Skip to content

Commit

Permalink
more specific check for function type (rAF and cAF)
Browse files Browse the repository at this point in the history
Check specifically that requestAnimationFrame and cancelAnimationFrame are functions, and not just that they are truthy.
  • Loading branch information
liady authored Sep 10, 2019
1 parent 2dc1147 commit 0562fb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/scheduler/src/forks/SchedulerHostConfig.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ if (
// Explicitly bind local references to `window`, in order to support
// environments where the global `this` is not the window (e.g extensions)
const requestAnimationFrame =
window.requestAnimationFrame && window.requestAnimationFrame.bind(window);
typeof window.requestAnimationFrame === 'function'
? window.requestAnimationFrame.bind(window)
: undefined;
const cancelAnimationFrame =
window.cancelAnimationFrame && window.cancelAnimationFrame.bind(window);
typeof window.cancelAnimationFrame === 'function'
? window.cancelAnimationFrame.bind(window)
: undefined;

if (typeof console !== 'undefined') {
// TODO: Remove fb.me link
Expand Down

0 comments on commit 0562fb5

Please sign in to comment.