You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing some crude interfacing with some js code (in IJulia for now). I've had cause to do something like this:
using Patchwork, Interact
@manipulate for curval in 0:0.1:10
Elem(:div, [
#other stuff...,
Elem(:script, "var best_global_evarrr = $curval"),
Elem(:script, "//ongoing process that uses best_global_evarrr")
])
end
When you move the slider, the text (code) of the first <script> gets patched, but the code doesn't get run. Seems that the whole <script> element actually needs to be removed and re-added, rather than just the text being modified in order for the browser to run it.
This change to diff.jl makes it work (only tested in chrome), but I don't know if it's the right solution.
@@ -98,7 +98,16 @@ function diff!{ns, tag}(a::Elem{ns, tag}, b::Elem{ns, tag}, index, patches)
patch = push!(patch, DictDiff(proppatch))
end
- diff!(a.children, b.children, index, patches, parentpatch=patch)
+ if tag == :script
+ scriptpatch = Dict()
+ diff!(a.children, b.children, 0, scriptpatch)
+ if !isempty(scriptpatch)
+ return patches[index] = Overwrite(b)
+ end
+ else
+ diff!(a.children, b.children, index, patches, parentpatch=patch)
+ end
+
if !isempty(patch)
patches[index] = patch
end
The text was updated successfully, but these errors were encountered:
I'm doing some crude interfacing with some js code (in IJulia for now). I've had cause to do something like this:
When you move the slider, the text (code) of the first
<script>
gets patched, but the code doesn't get run. Seems that the whole<script>
element actually needs to be removed and re-added, rather than just the text being modified in order for the browser to run it.This change to diff.jl makes it work (only tested in chrome), but I don't know if it's the right solution.
The text was updated successfully, but these errors were encountered: