bitovi/canjs — pull request #1048 by justinbmeyer (2014-06-04 03:41:49+00:00)
Title: Remove NodeLists from Stache

This not-working pull request begins the ability to remove nodeLists from can.stache. When fully implemented, this will dramatically improve live-binding performance in IE8.

## Short story

It is impossible in IE8 and lower to set expando properties on textNodes. For example, the following does not work:

```js
var tn = document.createTextNode("foo");
tn.expandoProperty = 5;
```

`can/view/node_list` maintains a map of element IDs to the live-binding `nodeList` that is keeping those elements live.

It is impossible to give an ID to a textNode so we must use an array instead. This changes a critical path in live-binding from O(1) to O(n) where n is the number of textNodes being live bound.

## Long story

For templates like:

```
{{#if foo}}FOO{{#if bar}}BaR{{/if}}.{{/if}}
```

It is important for the `{{#if foo}}` to know about all the elements it needs to remove. `can/view/nodeLists` helps us setup a structure that looks like:

```
[
"FOO",
["B",,"R"],
"."
]
```

where text nodes are represented by `"quotes"` and normal elements by ``.

This array of arrays structure is used to remove elements if `{{#if foo}}` was to become false.

## The fix

This branch includes a SectionNode construct which can represent `{{#if foo}}`. Child sections will have access to the parent SectionNodes.

When a live-bound element is found, it should check its parent SectionNode for the same element and replace the parent SectionNode's array's element with a pointer to the child SectionNode in a similar way that happens with NodeLists.

This will be MUCH faster for IE8 as it will only have to find the textNode that is being replaced within its parent Section's nodes.