Skip to content

Commit b84203c

Browse files
author
Travis Garvin Deprato
committed
Fix WebIO deprecations, add Project.toml.
1 parent 1dd7097 commit b84203c

File tree

5 files changed

+39
-16
lines changed

5 files changed

+39
-16
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
assets/knockout.js
66
assets/knockout_punches.js
77
deps/build.log
8-
8+
Manifest.toml

Project.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name = "Knockout"
2+
uuid = "bcebb21b-c2e3-54f8-a781-646b90f6d2cc"
3+
license = "MIT"
4+
version = "0.8.3"
5+
6+
[deps]
7+
JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660"
8+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
9+
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
10+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11+
WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"
12+
13+
[compat]
14+
WebIO = ">= 0.8.0"
15+
julia = "0.7, 1"
16+
17+
[extras]
18+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
19+
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
20+
21+
[targets]
22+
test = ["Blink", "Test"]

REQUIRE

-5
This file was deleted.

src/Knockout.jl

+16-9
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ You can pass functions that you want available in the Knockout scope as keyword
2424
`knockout` E.g. `knockout(...; methods=Dict(:sayhello=>@js function(){ alert("hello!") }))`
2525
"""
2626
function knockout(template, data=Dict(), extra_js = js""; computed = [], methods = [])
27-
id = WebIO.newid("knockout-component")
28-
widget = Scope(id;
29-
imports=Any["knockout" => knockout_js, "knockout_punches" => knockout_punches_js]
30-
)
31-
widget.dom = template
27+
widget = Scope(imports=[
28+
"knockout" => knockout_js,
29+
"knockout_punches" => knockout_punches_js,
30+
])
31+
widget(template)
3232
ko_data = Dict()
3333
watches = Dict()
3434
for (k, v) in data
@@ -75,23 +75,30 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods
7575
function (ko, koPunches) {
7676
ko.punches.enableAll();
7777
ko.bindingHandlers.numericValue = {
78-
init : function(element, valueAccessor, allBindings, data, context) {
78+
init: function(element, valueAccessor, allBindings, data, context) {
7979
var stringified = ko.observable(ko.unwrap(valueAccessor()));
8080
stringified.subscribe(function(value) {
8181
var val = parseFloat(value);
8282
if (!isNaN(val)) {
8383
valueAccessor()(val);
8484
}
85-
})
85+
});
8686
valueAccessor().subscribe(function(value) {
8787
var str = JSON.stringify(value);
8888
if ((str == "0") && (["-0", "-0."].indexOf(stringified()) >= 0))
8989
return;
9090
if (["null", ""].indexOf(str) >= 0)
9191
return;
9292
stringified(str);
93-
})
94-
ko.applyBindingsToNode(element, { value: stringified, valueUpdate: allBindings.get('valueUpdate')}, context);
93+
});
94+
ko.applyBindingsToNode(
95+
element,
96+
{
97+
value: stringified,
98+
valueUpdate: allBindings.get('valueUpdate'),
99+
},
100+
context,
101+
);
95102
}
96103
};
97104
var json_data = $ko_data;

test/REQUIRE

-1
This file was deleted.

0 commit comments

Comments
 (0)