Shopify/batman — Issue #221: [Patch] Bind IteratorBindings to the injected comment
Author: pvande
Created: 2011-11-09 01:51:07+00:00
State: open

This also allows Comment nodes to be unbound, and changed `$unbindTree` to do depth-first freeing of nodes.

``` diff
@@ -3494,11 +3494,11 @@ Batman.DOM = {
Batman.removeData node

# Unbinds the tree rooted at `node`.
- # When set to `false`, `unbindRoot` skips the `node` before unbinding all of its children.
- unbindTree: $unbindTree = (node, unbindRoot = true) ->
- return unless node?.nodeType is 1
- $unbindNode node if unbindRoot
+ # When set to `false`, `unbindThisNode` only unbinds this `node`'s children.
+ unbindTree: $unbindTree = (node, unbindThisNode = true) ->
+ return unless node?.nodeType in [1, 8]
$unbindTree(child) for child in node.childNodes
+ $unbindNode node if unbindThisNode

# Memory-safe setting of a node's innerHTML property
setInnerHTML: $setInnerHTML = (node, html, args...) ->
DiscardStage@@ -4064,7 +4064,7 @@ class Batman.DOM.IteratorBinding extends Batman.DOM.AbstractCollectionBinding
@parentRenderer.prevent 'rendered'

# Tie this binding to a node using Batman.data
- super(@parentNode, @iteratorName, @key, @context, @parentRenderer)
+ super(@siblingNode, @iteratorName, @key, @context, @parentRenderer)

@fragment = document.createDocumentFragment()
```