Open justinbmeyer opened 5 years ago
Check out these tests in can-stache for places where comment nodes are forced outside of can-view-target:
Seems like a pattern.
fix can-view-target so :
(bug is fixed)
target([{comment: "foo", callbacks: [function(){}]])
2 hrs
create two comment nodes for every range WHERE: can-stache/can-stache.js (or HTMLSection)
[
{comment: "#if(foo)", callbacks: [
function(startComment){
}
]},
{comment: "can-end-placeholder"}
]
1 hr
Makes sure if the next node is not a "can-end-placeholder", we are warning: https://github.com/canjs/can-view-live/blob/487f9d90caeef351bc508f8cb3494017a19091bc/lib/helpers.js#L71
1 hr
Run Stache Tests ... are there new weird cases?
1 hr - 2 days
Make it so functions returned by helpers are called with a placeholder.
For {{#each}}
, this should fix:
1. Double placeholders. Change:
<!-- #for(name in people) -->
<!-- people patcher -->
brad||justin
<!-- end patcher -->
<!-- /for -->
to
<!-- #for(name in people) -->
brad||justin
<!-- /for -->
2. Eliminate the warnings from #3
We will have to change:
can-view-live.html -
can-stache/core - https://github.com/canjs/can-stache/blob/bd5c98979f1cc770b2726f2cc932c0652fe2f8e6/src/mustache_core.js#L379
4 hrs
Check can-component / can-stache-bindings
Instead of an ending comment node like: {comment: "can-end-placeholder"} We will need to change that to: {comment: "/for"}
At min remove: next.nodeValue === "can-end-placeholder"
Possibly:
range.create(el){ return {start: el, end: el.nextSibling}; }
Can we change can-view-live
's tests to always make sure this is the case?
What about can-component?
@bmomberger-bitovi can you give an update on where you got on this?
What's complete by package:
Still to do:
For, point 4, running the can-stache
tests no longer produces any of these warnings:
can-view-live: creating an end comment for ...
can-view-live: forcing a comment range for ...
There are still a ton of these warnings: https://github.com/canjs/can-view-live/blob/805b4757a6e77db46737daf9ae2093c28338a434/lib/helpers.js#L20
Can you explain what this case is @justinbmeyer ?
To make building templates faster, make sure to render with comment nodes.
Currently,
can-stache
creates placeholder text nodes for anything "live" usingcan-view-target
.presentation
For stache like
start{{#if(foo)}}BAR{{/if}}end
instead of placeholder textNodes, create two comment nodes. Resulting DOM would look like:Before:
can-view-target
has already been changed to "force" comments instead of textNodes:https://github.com/canjs/can-view-live/blob/d541c95d04d6db7f6ec2988bc319c98c049328ea/lib/helpers.js#L63
If you have something like
{{foo}}
... this should create a placecholder textNode, however, there are times where you can opt out of this, likesafeString
or components, with those, we'd need to "force" into comment nodes.Approach
can-view-live
warn if it's forcing a "comment node". You will see a LOT of warnings withcan-view-target
, ignore those.can-stache
.Code you might want to change
instead of just adding a function, add two comment nodes: https://github.com/canjs/can-stache/blob/49fea89e3f919e21c941cb8c23090c61857a46ce/src/html_section.js#L60
should we be forcing comment nodes here: https://github.com/canjs/can-stache/blob/49fea89e3f919e21c941cb8c23090c61857a46ce/can-stache.js#L113
... or in the
.add()
function?