twine-rails 1.2.1 → 1.2.2

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
- SHA1:
3
- metadata.gz: 9a1f8a165f50cdc666899675823de067c31981e5
4
- data.tar.gz: 14a2d531c688fed6badb7144caee3ce4e54576b6
2
+ SHA256:
3
+ metadata.gz: f8b1f18347a673c2da36ccab84449031136b661d8184beb2cad56ea81e471a87
4
+ data.tar.gz: e64ca56b6851cb8f7dc692e31812d0745b2ccb9a7f7594f254ff6f1c1b339717
5
5
  SHA512:
6
- metadata.gz: 50f4bcd70db07b862872902aa7952b8e6918cf613cd9c316dd77914a8cce9c4b6daaa03aa6fd3636b1f4441e3bede39ecfe0dfd4307537e94b5caf577459b2fc
7
- data.tar.gz: 067ef8d649ec0933d121ec73a4b20880e8cc259a7f0e8d7ecbbb3ecaaa61de876b675d5c965c26208cbc5e06efde63512e3638be774aaaa90e21561a0ca4f926
6
+ metadata.gz: 23a2c7c69017ab0f289549aae0cd53d40ee09dfc04b956db63f4d9c4e5f26e0a20b9a56d996764b4e0b8a1b153d44fa8d1e44d52a6be82551dc82f61f293a34c
7
+ data.tar.gz: 5055a680b4b0a996b3c52c0f38a062e28427ff31a018c75a4d34ec49e846a8b58ccd3eeaa9052a6bea18fd5dab6d2d60b0ecf41f5e84365c42a3e4ae149c05b5
@@ -110,12 +110,9 @@
110
110
 
111
111
  callbacks = currentBindingCallbacks
112
112
 
113
- # IE and Safari don't support node.children for DocumentFragment and SVGElement nodes.
114
- # If the element supports children we continue to traverse the children, otherwise
115
- # we stop traversing that subtree.
116
- # https://developer.mozilla.org/en-US/docs/Web/API/ParentNode.children
117
- # As a result, Twine are unsupported within DocumentFragment and SVGElement nodes.
118
- bind(context, childNode, if newContextKey? then null else indexes) for childNode in (node.children || [])
113
+ # IE and Safari don't support node.children for DocumentFragment or SVGElement,
114
+ # See explanation in childrenForNode()
115
+ bind(context, childNode, if newContextKey? then null else indexes) for childNode in childrenForNode(node)
119
116
  Twine.count = nodeCount
120
117
 
121
118
  for callback in callbacks || []
@@ -124,6 +121,18 @@
124
121
 
125
122
  Twine
126
123
 
124
+ # IE and Safari don't support node.children for DocumentFragment and SVGElement nodes.
125
+ # If the element supports children we continue to traverse the children, otherwise
126
+ # we stop traversing that subtree.
127
+ # https://developer.mozilla.org/en-US/docs/Web/API/ParentNode.children
128
+ # As a result, Twine are unsupported within DocumentFragment and SVGElement nodes.
129
+ #
130
+ # We also prevent nodes from being iterated over more than once by cacheing the
131
+ # lookup for children nodes, which prevents nodes that are dynamically inserted
132
+ # or removed as siblings from causing double/ missed binds and unbinds.
133
+ childrenForNode = (node) ->
134
+ if node.children then Array::slice.call(node.children, 0) else []
135
+
127
136
  findOrCreateElementForNode = (node) ->
128
137
  node.bindingId ?= ++nodeCount
129
138
  elements[node.bindingId] ?= {}
@@ -169,10 +178,9 @@
169
178
  delete elements[id]
170
179
  delete node.bindingId
171
180
 
172
-
173
181
  # IE and Safari don't support node.children for DocumentFragment or SVGElement,
174
- # See explaination in bind()
175
- Twine.unbind(childNode) for childNode in (node.children || [])
182
+ # See explanation in childrenForNode()
183
+ Twine.unbind(childNode) for childNode in childrenForNode(node)
176
184
  this
177
185
 
178
186
  # Returns the binding context for a node by looking up the tree.
@@ -1,3 +1,3 @@
1
1
  module TwineRails
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twine-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Li
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-02-16 00:00:00.000000000 Z
13
+ date: 2018-10-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-rails
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.6.14
103
+ rubygems_version: 2.7.6
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Minimalistic two-way bindings