opal-virtual-dom 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/opal-virtual-dom.gemspec +1 -1
- data/opal/virtual_dom/dom.rb +15 -17
- data/opal/virtual_dom/virtual_node.rb +5 -6
- metadata +2 -3
- data/opal/virtual_dom/virtual_text_node.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 401a70f8753aef7fce8a51c5ab95b3465a042685
|
4
|
+
data.tar.gz: 3a9a07a08771f8396e1bef15f6b1fa91e282e3a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad3c3671d1684e8877e7faaf9a6013babec2286f438c0ef03d23c08690a19117317c0e0ad7d51dcc0dbd82821c125f2331ce1381f2849513c53db4ed94ffc5d
|
7
|
+
data.tar.gz: 44a3b43d32e3f4ee82e575bd7d8990e4a846db382a6d0a0b97ba5863ec1d126f2e6536ae5d861ea28bef8d1e7eaf68688d99f4e7e022eb2f3f9060e7792fa67e
|
data/opal-virtual-dom.gemspec
CHANGED
data/opal/virtual_dom/dom.rb
CHANGED
@@ -15,36 +15,34 @@ module VirtualDOM
|
|
15
15
|
if block
|
16
16
|
current = @__virtual_nodes__
|
17
17
|
@__virtual_nodes__ = []
|
18
|
-
result = block.call
|
19
|
-
vnode = VirtualNode.new(tag, process_params(params), @__virtual_nodes__.count == 0 ? result : @__virtual_nodes__).
|
18
|
+
result = block.call || ''
|
19
|
+
vnode = VirtualNode.new(tag, process_params(params), @__virtual_nodes__.count == 0 ? result : @__virtual_nodes__).to_n
|
20
20
|
@__virtual_nodes__ = current
|
21
21
|
else
|
22
|
-
vnode = VirtualNode.new(tag, process_params(params), []).
|
22
|
+
vnode = VirtualNode.new(tag, process_params(params), []).to_n
|
23
23
|
end
|
24
24
|
@__virtual_nodes__ << vnode
|
25
25
|
vnode
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def text(string)
|
30
|
-
@__virtual_nodes__ << VirtualTextNode.new(string).vnode
|
31
|
-
end
|
32
|
-
|
33
29
|
def process_params(params)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
30
|
+
return {} unless params.is_a?(Hash)
|
31
|
+
params.each do |k, v|
|
32
|
+
case k
|
33
|
+
when 'class'
|
34
|
+
params['className'] = params.delete('class')
|
35
|
+
when /^on/
|
36
|
+
params[k] = ->(e) { v.call(Native(e)) }
|
42
37
|
end
|
43
|
-
else
|
44
|
-
{}
|
45
38
|
end
|
46
39
|
end
|
47
40
|
|
41
|
+
# for backwards compatibility, you can return string
|
42
|
+
def text(string)
|
43
|
+
@__virtual_nodes__ << string.to_s
|
44
|
+
end
|
45
|
+
|
48
46
|
# for backwards compatibility
|
49
47
|
def virtual_dom(&block)
|
50
48
|
block.call
|
@@ -6,7 +6,7 @@ module VirtualDOM
|
|
6
6
|
@childrens = childrens
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def to_n
|
10
10
|
`virtualDom.h(#{@name}, #{@params.to_n}, #{@childrens})`
|
11
11
|
end
|
12
12
|
|
@@ -15,11 +15,10 @@ module VirtualDOM
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_s_params
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
return unless @params.any?
|
19
|
+
' ' + @params.map do |k, v|
|
20
|
+
"#{k}=\"#{v}\""
|
21
|
+
end.join(' ')
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-virtual-dom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Kalbarczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- opal/virtual_dom.rb
|
54
54
|
- opal/virtual_dom/dom.rb
|
55
55
|
- opal/virtual_dom/virtual_node.rb
|
56
|
-
- opal/virtual_dom/virtual_text_node.rb
|
57
56
|
- opal/virtual_dom/wrapper.rb
|
58
57
|
homepage: http://github.com/fazibear/opal-virtual-dom
|
59
58
|
licenses: []
|