From b84203cf66a8e9c4c5f60811fbe8fc38c1af85e5 Mon Sep 17 00:00:00 2001 From: Travis Garvin Deprato Date: Sun, 9 Jun 2019 22:06:34 -0700 Subject: [PATCH 1/3] Fix WebIO deprecations, add Project.toml. --- .gitignore | 2 +- Project.toml | 22 ++++++++++++++++++++++ REQUIRE | 5 ----- src/Knockout.jl | 25 ++++++++++++++++--------- test/REQUIRE | 1 - 5 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 Project.toml delete mode 100644 REQUIRE delete mode 100644 test/REQUIRE diff --git a/.gitignore b/.gitignore index 98ed3d6..570279c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ assets/knockout.js assets/knockout_punches.js deps/build.log - +Manifest.toml diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..d7a8fe1 --- /dev/null +++ b/Project.toml @@ -0,0 +1,22 @@ +name = "Knockout" +uuid = "bcebb21b-c2e3-54f8-a781-646b90f6d2cc" +license = "MIT" +version = "0.8.3" + +[deps] +JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660" +JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +Observables = "510215fc-4207-5dde-b226-833fc4488ee2" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" + +[compat] +WebIO = ">= 0.8.0" +julia = "0.7, 1" + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Blink = "ad839575-38b3-5650-b840-f874b8c74a25" + +[targets] +test = ["Blink", "Test"] diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index 7ccbb63..0000000 --- a/REQUIRE +++ /dev/null @@ -1,5 +0,0 @@ -julia 0.7 -WebIO 0.3.0 -Observables 0.2.2 -JSExpr -JSON diff --git a/src/Knockout.jl b/src/Knockout.jl index 6f7c936..14af1c2 100644 --- a/src/Knockout.jl +++ b/src/Knockout.jl @@ -24,11 +24,11 @@ You can pass functions that you want available in the Knockout scope as keyword `knockout` E.g. `knockout(...; methods=Dict(:sayhello=>@js function(){ alert("hello!") }))` """ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods = []) - id = WebIO.newid("knockout-component") - widget = Scope(id; - imports=Any["knockout" => knockout_js, "knockout_punches" => knockout_punches_js] - ) - widget.dom = template + widget = Scope(imports=[ + "knockout" => knockout_js, + "knockout_punches" => knockout_punches_js, + ]) + widget(template) ko_data = Dict() watches = Dict() for (k, v) in data @@ -75,14 +75,14 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods function (ko, koPunches) { ko.punches.enableAll(); ko.bindingHandlers.numericValue = { - init : function(element, valueAccessor, allBindings, data, context) { + init: function(element, valueAccessor, allBindings, data, context) { var stringified = ko.observable(ko.unwrap(valueAccessor())); stringified.subscribe(function(value) { var val = parseFloat(value); if (!isNaN(val)) { valueAccessor()(val); } - }) + }); valueAccessor().subscribe(function(value) { var str = JSON.stringify(value); if ((str == "0") && (["-0", "-0."].indexOf(stringified()) >= 0)) @@ -90,8 +90,15 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods if (["null", ""].indexOf(str) >= 0) return; stringified(str); - }) - ko.applyBindingsToNode(element, { value: stringified, valueUpdate: allBindings.get('valueUpdate')}, context); + }); + ko.applyBindingsToNode( + element, + { + value: stringified, + valueUpdate: allBindings.get('valueUpdate'), + }, + context, + ); } }; var json_data = $ko_data; diff --git a/test/REQUIRE b/test/REQUIRE deleted file mode 100644 index 12266c1..0000000 --- a/test/REQUIRE +++ /dev/null @@ -1 +0,0 @@ -Blink 0.8.0 From 7872847d1e378db07bb7f95dea6894a4ff520aa9 Mon Sep 17 00:00:00 2001 From: Travis Garvin Deprato Date: Sun, 9 Jun 2019 22:11:18 -0700 Subject: [PATCH 2/3] Fix TravisCI config. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c180b8..88e53f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,6 @@ branches: - /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - $TESTCMD -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Knockout"); Pkg.test("Knockout"; coverage=true)' + - $TESTCMD -e 'using Pkg; Pkg.build(); Pkg.test("Knockout"; coverage=true)' after_success: - julia -e coverage.jl From ba46216063ac89eb2cdb84c388f9676cc4f1fd41 Mon Sep 17 00:00:00 2001 From: Travis DePrato <773453+travigd@users.noreply.github.com> Date: Mon, 10 Jun 2019 08:48:50 -0700 Subject: [PATCH 3/3] Fix version. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d7a8fe1..1da8850 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Knockout" uuid = "bcebb21b-c2e3-54f8-a781-646b90f6d2cc" license = "MIT" -version = "0.8.3" +version = "0.2.3" [deps] JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660"