opal-virtual-dom 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4af4fe73f545fc7348b1d934787ed5e0e5b9a89
4
- data.tar.gz: 589de3ba4f5452c06c291990d01be9a2b5d2e9b0
3
+ metadata.gz: 5d1742e56e1a41c661d1e5187dfb2039b7659cb4
4
+ data.tar.gz: ae392be98fcf7b952ffb88199ae557589905fac8
5
5
  SHA512:
6
- metadata.gz: 9c1e0d821df239bec6bf705c0058f05efa704f3d5e44d99dc789f15f6dc17b015af4aa387e7885a8adf87c3d0343fbfb32900adcacd9dc396a54e6463a33ec04
7
- data.tar.gz: c38ad25dbe2d01109aee4108c3114f9adf49859f6ae45ccf10c4be666524d752e4983dec715b0401c59b1ba13ea71b6c16e3942827b8b519a5a0fa93288aa1a8
6
+ metadata.gz: e498df234779e09b5dff8bd0f86eb5f45c5833a82c3b19dbed4b74c97b1f879536127193418dd2861409a394eb4b5eb9094247bfd44b56fef7bfdfa98cef3e61
7
+ data.tar.gz: e81c93af95ca6f2d3602b83e5d410a14465e05cdf426ae007d2cf2ef8633e1259b39a1a89100e90ab5323824b42997bbe302920408a1da0cfbd32f81efbbbe8a
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opal-virtual-dom'
3
- s.version = '0.5.0'
3
+ s.version = '0.5.1'
4
4
  s.authors = ['Michał Kalbarczyk']
5
5
  s.email = 'fazibear@gmail.com'
6
6
  s.homepage = 'http://github.com/fazibear/opal-virtual-dom'
@@ -11,22 +11,24 @@ module VirtualDOM
11
11
 
12
12
  HTML_TAGS.each do |tag|
13
13
  define_method tag do |params = {}, &block|
14
- process_tag(tag, params, block)
14
+ if params.is_a?(String)
15
+ process_tag(tag, {}, block, params)
16
+ elsif params.is_a?(Hash)
17
+ process_tag(tag, params, block)
18
+ end
15
19
  end
16
20
  end
17
21
 
18
- def process_tag(tag, params, block)
22
+ def process_tag(tag, params, block, children = [])
19
23
  @__virtual_nodes__ ||= []
20
24
  if block
21
25
  current = @__virtual_nodes__
22
26
  @__virtual_nodes__ = []
23
- result = block.call || ''
27
+ result = block.call || children
24
28
  vnode = VirtualNode.new(tag, process_params(params), @__virtual_nodes__.count.zero? ? result : @__virtual_nodes__)
25
29
  @__virtual_nodes__ = current
26
- elsif params.is_a?(String)
27
- vnode = VirtualNode.new(tag, {}, [params])
28
30
  else
29
- vnode = VirtualNode.new(tag, process_params(params), [])
31
+ vnode = VirtualNode.new(tag, process_params(params), children)
30
32
  end
31
33
  @__last_virtual_node__ = vnode
32
34
  @__virtual_nodes__ << @__last_virtual_node__.to_n
@@ -37,6 +39,13 @@ module VirtualDOM
37
39
  return unless @__last_virtual_node__
38
40
  return unless @__virtual_nodes__
39
41
  @__virtual_nodes__.pop
42
+ children = []
43
+
44
+ if params.is_a?(String)
45
+ children = [params]
46
+ params = {}
47
+ end
48
+
40
49
  class_params = @__last_virtual_node__.params.delete(:className)
41
50
  method_params = if clazz.end_with?('!')
42
51
  { id: clazz[0..-2],
@@ -45,7 +54,7 @@ module VirtualDOM
45
54
  { class: merge_string(class_params, params[:class], clazz) }
46
55
  end
47
56
  params = @__last_virtual_node__.params.merge(params).merge(method_params)
48
- process_tag(@__last_virtual_node__.name, params, block)
57
+ process_tag(@__last_virtual_node__.name, params, block, children)
49
58
  end
50
59
 
51
60
  def merge_string(*params)
@@ -58,7 +67,6 @@ module VirtualDOM
58
67
  end
59
68
 
60
69
  def process_params(params)
61
- return {} unless params.is_a?(Hash)
62
70
  params.dup.each do |k, v|
63
71
  case k
64
72
  when 'class'
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Kalbarczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2017-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.5.1
85
+ rubygems_version: 2.6.13
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: virtual-dom wrapper for opal