Remove NodeLists from Stache #1048
Merged
+575
−296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
can/view/node_list
maintains a map of element IDs to the live-bindingnodeList
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:
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:where text nodes are represented by
"quotes"
and normal elements by<angles>
.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.