dom-rb 0.1.4 → 0.1.5

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: 9cae4bc31b6b58eba444410662c49f6fc38956b8
4
- data.tar.gz: 7d6094522646022477e1e18822ec3dbf01ec37f2
3
+ metadata.gz: 506d56aaaa6c084470621a2b06ede1564a619014
4
+ data.tar.gz: 41005f31a9cda1c1106ce501307f3bbab5a47735
5
5
  SHA512:
6
- metadata.gz: 4a6e6c87150dd87203d089ddb08357ecc6a72bf46f26f1f7395198b77a9986985d49aa2c5a210e18caf08a227d84ad980bce334c20a767afdc99dedd567be8bc
7
- data.tar.gz: bd12f013b96489a59961d0cebb0f8c6a312ed93e8f2a3eeb4e832dff06f83e26b692e81b28ef2c88d1239e97608db154c845d94c5b6cacb6119dbc144087dcb1
6
+ metadata.gz: 63ec0c8fe718cc6e45a8acea70f090b334cd442f2d8e58ae17eec03dbe7ee4fc256c05ed2e016fb5d7c8c0fd5090ef8fcadb84297d318439d76cd6a9bc622348
7
+ data.tar.gz: 9eea6f3341e0a9421748e0a2b7c995930b5595be4071b77db2572e41cdb2eeff52d9ae2da86fd63aa7f465bf4ce5be4aaaeff6c103935dc5ac817acd220016ef
@@ -51,7 +51,7 @@ module CSR
51
51
  def icon_with_anchor(icon_name, href, icon_attributes: nil, anchor_attributes: nil, tooltip: nil, popover: nil)
52
52
  attributes = { href: href }
53
53
  if anchor_attributes
54
- attributes = anchor_attributes.merge(attributes)
54
+ attributes = merge_attributes(anchor_attributes, attributes)
55
55
  end
56
56
  tag(
57
57
  :a,
@@ -68,7 +68,7 @@ module CSR
68
68
  }
69
69
  if icon_attributes
70
70
  # argument takes precedence
71
- _icon_attributes = _icon_attributes.merge(icon_attributes)
71
+ _icon_attributes = merge_attributes(_icon_attributes, icon_attributes)
72
72
  end
73
73
  icon_with_anchor(
74
74
  :plus_sign,
@@ -132,7 +132,7 @@ module CSR
132
132
  class: "dropdown-menu#{menu_right ? ' dropdown-menu-right' : nil}"
133
133
  }
134
134
  if menu_attributes
135
- _menu_attributes = _menu_attributes.merge(menu_attributes)
135
+ _menu_attributes = merge_attributes(_menu_attributes, menu_attributes)
136
136
  end
137
137
  tag(
138
138
  :div,
@@ -191,7 +191,9 @@ module CSR
191
191
  }
192
192
  if icon_attributes
193
193
  # argument attributes take precedence
194
- _icon_attributes = _icon_attributes.merge(icon_attributes)
194
+ debug 0, ->{[__FILE__, __LINE__, __method__, "_icon_attributes=#{_icon_attributes} icon_attributes=#{icon_attributes}"]}
195
+ _icon_attributes = merge_attributes(_icon_attributes, icon_attributes)
196
+ debug 0, ->{[__FILE__, __LINE__, __method__, "_icon_attributes=#{_icon_attributes}"]}
195
197
  end
196
198
  drop_down_icon(
197
199
  icon: 'plus-sign',
@@ -242,9 +244,10 @@ module CSR
242
244
  end
243
245
  tag(
244
246
  :div,
245
- attributes: {
246
- style: { cursor: 'pointer' }
247
- }.merge(attributes || {}),
247
+ attributes: merge_attributes(
248
+ { style: { cursor: 'pointer' } },
249
+ attributes
250
+ ),
248
251
  content: arrify(content, icon)
249
252
  )
250
253
  end
@@ -203,6 +203,7 @@ module CSR
203
203
  def update
204
204
  debug 2, ->{[ __FILE__, __LINE__, __method__ ]}
205
205
  init_sorting
206
+ @caption = @sections = nil
206
207
  update_root
207
208
  end
208
209
 
@@ -49,6 +49,25 @@ module CSR
49
49
  result
50
50
  end
51
51
 
52
+ # args are hashes, lowest to highest precedence
53
+ # TODO: only handles two levels deep (style, onclick, ...)
54
+ def merge_attributes(*args)
55
+ result = args[0] || {}
56
+ args.each do |arg|
57
+ if arg
58
+ arg.each_pair do |k,v|
59
+ prev = result[k]
60
+ if Hash == v && Hash === prev
61
+ result[k] = v.merge(prev)
62
+ else
63
+ result[k] = v
64
+ end
65
+ end
66
+ end
67
+ end
68
+ result
69
+ end
70
+
52
71
  # make a single array from args
53
72
  # args may be mix of non-enumerables and enumerables
54
73
  # nils will not be included
@@ -1,5 +1,5 @@
1
1
  module CSR
2
2
  module DOM
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dom-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Gunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-05 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal-browser