-
Notifications
You must be signed in to change notification settings - Fork 12
Description
To make building templates faster, make sure to render with comment nodes.
Currently, can-stache creates placeholder text nodes for anything "live" using can-view-target.
For stache like start{{#if(foo)}}BAR{{/if}}end instead of placeholder textNodes, create two comment nodes. Resulting DOM would look like:
start<!-- Observe<if(foo)> -->BAR<!-- Observe<if(foo)> -->end
Before:
hydrate([
"start",
function(){ this //-> text node
},
"end"
])
hydrate([
"start",
{comment: "{{ if(foo) }}", callbacks: [ function(){} ]},
{comment: "{{ /if }}"
"end"
])
can-view-target has already been changed to "force" comments instead of textNodes:
If you have something like {{foo}} ... this should create a placecholder textNode, however, there are times where you can opt out of this, like safeString or components, with those, we'd need to "force" into comment nodes.
Approach
- Create a performance test
- Make
can-view-livewarn if it's forcing a "comment node". You will see a LOT of warnings withcan-view-target, ignore those. - Make those warnings going away in
can-stache. - Remove the warnings?
Code you might want to change
instead of just adding a function, add two comment nodes:
can-stache/src/html_section.js
Line 60 in 49fea89
| this.last().add(newSection.targetCallback); |
should we be forcing comment nodes here:
Line 113 in 49fea89
| section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, copyState({ filename: section.filename, lineNo: lineNo }))); |
... or in the .add() function?