Closed AugustNagro closed 3 years ago
We use comments because we need to insert some sigil in the HTML to find expressions, and comments don't interact with HTML parsing quirks like the adoption agency algorithm (what handles <table>
etc). We insert comments to serve as the start nodes for expressions mainly to have more consistent setup for parsed parts and dynamically created parts. In lit-html 2.0 we're redicing the number of comment nodes, but this should be a transparent change.
Thanks. I checked out the source over the weekend and see now why markers are needed in the context of the render function. Interesting to know about the adoption agency algorithm.
This and lit-html are cool libraries and I was surprised the source is so small and readable.
lit-html currently surrounds Elements it may need to update with two
<!---->
comment elements.For example, lets say you have
Then lit-element is output two comment nodes and four text node. Whenever a data dependency changes, the respective node is re-rendered.
But why the comments? Would it be more expedient to save references to the nodes when you build, instead of using the comments to locate?