From 4898a9e2c25533bbf997af580da626471c1f0336 Mon Sep 17 00:00:00 2001 From: Cort Spellman Date: Tue, 17 Mar 2020 00:04:01 -0500 Subject: [PATCH] Fix re-rendering in content scripts in Firefox extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a problem with Reagent in content scripts in Firefox extensions where the UI does not update when a ratom changes. The problem is described here https://github.com/NoxHarmonium/reagent/commit/a9e898cd74b53fd3321fe7e122fb3d1ddef91495 with Reagent 0.9.0+, though that Reagent fork also has a branch that patches Reagent 0.8.1. The relevant branches are: * fix-raf-binding-0.8.1 * fix-raf-binding-0.9.0-rc1 * master (with fix on 0.9.0) Note the "related links section" of the commit message at the above link: React issue https://github.com/facebook/react/issues/16606 From what I’ve read, this only seems to affect content scripts in browser extensions in Firefox. I have merely applied the fix in the commit at the above link to Reagent 0.10.0. [#170650669] --- src/reagent/impl/batching.cljs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/reagent/impl/batching.cljs b/src/reagent/impl/batching.cljs index 03b4d460..88a7c251 100644 --- a/src/reagent/impl/batching.cljs +++ b/src/reagent/impl/batching.cljs @@ -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 [^clj c1 ^clj c2]