Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($$RAFProvider): prevent a JavaScript error in Firefox #16192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix($$RAFProvider): prevent a JavaScript error in Firefox
Firefox raises a Javascript Error "TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window." with animated elements. This is because Window.requestAnimationFrame() is called without binding to a Window instance in the function which is returned from $$RAFProvider().
  • Loading branch information
dmuellner committed Aug 23, 2017
commit f709decd9398c7519fd899ea8d7ca40cd8e4666f
4 changes: 2 additions & 2 deletions src/ng/raf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function $$RAFProvider() { //rAF
var rafSupported = !!requestAnimationFrame;
var raf = rafSupported
? function(fn) {
var id = requestAnimationFrame(fn);
var id = requestAnimationFrame.bind($window, fn);
Copy link
Contributor

@frederikprijck frederikprijck Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you mean to use call instead of bind here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Thanks! I'll commit a fix in a minute.

return function() {
cancelAnimationFrame(id);
cancelAnimationFrame.bind($window, id);
Copy link
Contributor

@frederikprijck frederikprijck Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you mean to use call instead of bind here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Thanks! I'll commit a fix in a minute.

};
}
: function(fn) {
Expand Down