From fe421f5c6fc70d8e0bf4c1c1bf92d62110e6f2a5 Mon Sep 17 00:00:00 2001 From: Nathan Daly Date: Mon, 8 Jan 2018 20:36:14 -0600 Subject: [PATCH] Fixes #109. Always calls `evalscripts` in `fill`. Moves the fade/no-fade decision from julia down into javascript, so that more code can be reused between the two. This also simplifies the `content!` function body, which will make fixing #108 a bit easier. Updates "Fade False" test to not @test_throws. Tests still pass. --- res/blink.js | 15 ++++++++++++--- src/content/api.jl | 8 +++----- test/api.jl | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/res/blink.js b/res/blink.js index 9ce61ac..cf1e7ae 100644 --- a/res/blink.js +++ b/res/blink.js @@ -97,18 +97,27 @@ } } - function fill(node, html) { + function fill(node, html, fade) { + node = select(node); + fade ? + fillfade(node, html) : + fillnofade(node, html) + } + function fillfade(node, html) { node = select(node); node.classList.add('blink-show'); callback(function () { node.classList.add('blink-fade'); callback(0.2, function() { - node.innerHTML = html; - evalscripts(node); + fillnofade(node, html); node.classList.remove('blink-fade'); }); }); } + function fillnofade(node, html) { + node.innerHTML = html; + evalscripts(node); + } Blink.fill = fill; diff --git a/src/content/api.jl b/src/content/api.jl index 7d0cfdc..2408e36 100644 --- a/src/content/api.jl +++ b/src/content/api.jl @@ -1,11 +1,9 @@ export body!, content!, loadcss!, loadjs!, load!, importhtml! -content!(o, sel, html::AbstractString; fade = true) = - fade ? - @js_(o, Blink.fill($sel, $html)) : - @js_ o document.querySelector($sel).innerHTML = $html +content!(o, sel, html::AbstractString; fade=true) = + @js_(o, Blink.fill($sel, $html, $fade)) -content!(o, sel, html; fade = true) = +content!(o, sel, html; fade=true) = content!(o, sel, stringmime(MIME"text/html"(), html), fade = fade) body!(w, html; fade = true) = content!(w, "body", html, fade = fade) diff --git a/test/api.jl b/test/api.jl index 4c26cc0..6c9aa43 100644 --- a/test/api.jl +++ b/test/api.jl @@ -30,6 +30,6 @@ using Base.Test w = Window(Blink.@d(:show => false)); sleep(5.0) body!(w, fadeTestHtml; fade=false); sleep(1.0) - @test_throws Blink.JSError (@js w testJS) == "test" # THIS IS AN ERROR, should not throw. + @test (@js w testJS) == "test" end end