Commit 6ee7078af0bc52f378b9ee757501631e80091970
html-element: handle bind condition where items were added to an element manually
Matt McKegg committed on 6/28/2017, 7:25:37 AMParent: 0f95e238e7d990af64891bac02844a39e4c0cac1
Files changed
html-element.js | changed |
html-element.js | ||
---|---|---|
@@ -122,9 +122,9 @@ | ||
122 | 122 … | function handleChange (change) { |
123 | 123 … | for (var i = 0; i < change.addedNodes.length; i++) { |
124 | 124 … | // if parent is a mutant element, then safe to assume it has already been bound |
125 | 125 … | var node = change.addedNodes[i] |
126 | - if (!caches.has(node.parentNode)) { | |
126 … | + if (!caches.has(node.parentNode) || !isBound(node)) { | |
127 | 127 … | walk(node, rebind) |
128 | 128 … | } |
129 | 129 … | } |
130 | 130 … | for (var i = 0; i < change.removedNodes.length; i++) { |
@@ -226,8 +226,21 @@ | ||
226 | 226 … | } |
227 | 227 … | } |
228 | 228 … | } |
229 | 229 … | |
230 … | +function isBound (node) { | |
231 … | + if (node.nodeType === 1) { | |
232 … | + var data = caches.get(node) | |
233 … | + if (data) { | |
234 … | + return data.bindings.some(getBound) | |
235 … | + } | |
236 … | + } | |
237 … | +} | |
238 … | + | |
239 … | +function getBound (binding) { | |
240 … | + return binding.bound | |
241 … | +} | |
242 … | + | |
230 | 243 … | function invokeBind (binding) { |
231 | 244 … | binding.bind() |
232 | 245 … | } |
233 | 246 … |
Built with git-ssb-web