Skip to content

Commit

Permalink
Bind requestAnimationFrame to window
Browse files Browse the repository at this point in the history
* Browser extensions in Firefox have a weird issue where functions that
are on the DOM or on window cannot be assigned to a variable without
being bound to the context they came from
* Related links:
** https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html#pitfalls
** https://github.com/bvaughn/react-virtualized/pull/1013/files
** Semantic-Org/Semantic-UI#3855
  • Loading branch information
NoxHarmonium authored and Sean Dawson committed Sep 21, 2019
1 parent 5483424 commit a9e898c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject reagent "0.9.0-rc1"
(defproject reagent "0.9.0-rc1-BINDFIX"
:url "http://github.com/reagent-project/reagent"
:license {:name "MIT"}
:description "A simple ClojureScript interface to React"
Expand Down
11 changes: 5 additions & 6 deletions src/reagent/impl/batching.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
(def next-tick
(if-not is-client
fake-raf
(let [w js/window]
(or (.-requestAnimationFrame w)
(.-webkitRequestAnimationFrame w)
(.-mozRequestAnimationFrame w)
(.-msRequestAnimationFrame w)
fake-raf))))
(or (. (. js/window -requestAnimationFrame) bind js/window)
(. (. js/window -webkitRequestAnimationFrame) bind js/window)
(. (. js/window -mozRequestAnimationFrame) bind js/window)
(. (. js/window -msRequestAnimationFrame) bind js/window)
fake-raf)))

(defn compare-mount-order
[c1 c2]
Expand Down

0 comments on commit a9e898c

Please sign in to comment.