Skip to content

Commit b57b73d

Browse files
authored
Merge pull request #29 from JuliaGizmos/fix-scopeid-deprecation
Fix scopeid deprecation.
2 parents 015f46a + 975cc73 commit b57b73d

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
Manifest.toml

Project.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name = "JSExpr"
2+
uuid = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660"
3+
license = "MIT"
4+
version = "0.5.1"
5+
6+
[deps]
7+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
8+
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
9+
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
10+
WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"
11+
12+
[compat]
13+
julia = "0.7, 1"
14+
Observables = "0.2.2"
15+
WebIO = "0.8.5"
16+
17+
[extras]
18+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
19+
20+
[targets]
21+
test = ["Test"]

src/JSExpr.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module JSExpr
55
using JSON, MacroTools, WebIO
66
export JSString, @js, @js_str, @var, @new
77

8-
import WebIO: JSString, JSONContext, JSEvalSerialization
8+
import WebIO: JSString, JSONContext, JSEvalSerialization, scopeid
99
using Observables: AbstractObservable
1010

1111
macro js(expr)
@@ -64,7 +64,7 @@ function jsexpr(o::AbstractObservable)
6464
scope = _scope.value
6565

6666
obsobj = Dict("type" => "observable",
67-
"scope" => scope.id,
67+
"scope" => scopeid(scope),
6868
"name" => name,
6969
"id" => WebIO.obsid(o))
7070

test/runtests.jl

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using JSExpr
22
using WebIO
3+
import WebIO: scopeid
34
using Test
45

56
@testset "@js_str" begin
@@ -70,14 +71,14 @@ end
7071
end) == js"var acc=0; for(var i = 1; i <= 10; i = i + 2){acc+=1}"
7172

7273
@testset "observable interpolation" begin
73-
w = Scope("testwidget2")
74+
w = Scope()
7475
ob = Observable(0)
7576
@test_throws ErrorException @js $ob
7677

7778
ob = Observable{Any}(w, "test", nothing)
78-
@test @js($ob) == js"{\"name\":\"test\",\"scope\":\"testwidget2\",\"id\":\"ob_02\",\"type\":\"observable\"}"
79+
@test @js($ob) == js"{\"name\":\"test\",\"scope\":$(scopeid(w)),\"id\":\"ob_02\",\"type\":\"observable\"}"
7980

80-
@test @js($ob[]) == js"WebIO.getval({\"name\":\"test\",\"scope\":\"testwidget2\",\"id\":\"ob_02\",\"type\":\"observable\"})"
81-
@test @js($ob[] = 1) == js"WebIO.setval({\"name\":\"test\",\"scope\":\"testwidget2\",\"id\":\"ob_02\",\"type\":\"observable\"},1)"
81+
@test @js($ob[]) == js"WebIO.getval({\"name\":\"test\",\"scope\":$(scopeid(w)),\"id\":\"ob_02\",\"type\":\"observable\"})"
82+
@test @js($ob[] = 1) == js"WebIO.setval({\"name\":\"test\",\"scope\":$(scopeid(w)),\"id\":\"ob_02\",\"type\":\"observable\"},1)"
8283
end
8384
end

0 commit comments

Comments
 (0)