-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatchworkpatch.jl
31 lines (25 loc) · 1.05 KB
/
patchworkpatch.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#special casing script tags so that they get removed and re-added on a change
#this ensures any js updates get run. We need this for Interact to work.
#see: https://github.com/shashi/Patchwork.jl/issues/14
println("Mathbox.jl needs to overwrite Patchwork's diff!(Elem{ns, tag}, Elem{ns, tag}, Any, Any) - you can ignore the warning below.\n")
import Patchwork: Patch, DictDiff, Overwrite, diff!
function diff!{ns, tag}(a::Elem{ns, tag}, b::Elem{ns, tag}, index, patches)
if a === b return patches end
patch = get(patches, index, Patch[])
proppatch = Patchwork.diff(properties(a), properties(b))
if !is(proppatch, nothing)
patch = push!(patch, DictDiff(proppatch))
end
if tag == :script && ns == :xhtml
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
end