Skip to content

Commit a9e898c

Browse files
NoxHarmoniumSean Dawson
authored and
Sean Dawson
committed
Bind requestAnimationFrame to window
* 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
1 parent 5483424 commit a9e898c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject reagent "0.9.0-rc1"
1+
(defproject reagent "0.9.0-rc1-BINDFIX"
22
:url "http://github.com/reagent-project/reagent"
33
:license {:name "MIT"}
44
:description "A simple ClojureScript interface to React"

src/reagent/impl/batching.cljs

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
(def next-tick
1717
(if-not is-client
1818
fake-raf
19-
(let [w js/window]
20-
(or (.-requestAnimationFrame w)
21-
(.-webkitRequestAnimationFrame w)
22-
(.-mozRequestAnimationFrame w)
23-
(.-msRequestAnimationFrame w)
24-
fake-raf))))
19+
(or (. (. js/window -requestAnimationFrame) bind js/window)
20+
(. (. js/window -webkitRequestAnimationFrame) bind js/window)
21+
(. (. js/window -mozRequestAnimationFrame) bind js/window)
22+
(. (. js/window -msRequestAnimationFrame) bind js/window)
23+
fake-raf)))
2524

2625
(defn compare-mount-order
2726
[c1 c2]

0 commit comments

Comments
 (0)