-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Collapse consecutive text nodes #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If this is what I think it is, the comments could actually be useful for progressive enhancement. See ractivejs/ractive#2664 Basically, merged text nodes mean that there's no way not to replace consecutive text content (e.g. text in a section surrounded by other text and interpolators) without touching the DOM in ways that most people find surprising. |
Ah, interesting. In cases like this... <p>hello world!</p>
<!-- corresponds to -->
<p>hello {{world}}!</p> – Svelte generates three text nodes where there was previously only one. I think it's better if we don't assume that the server-rendered HTML came from a particular source, so we can't rely on comments being present in those cases. We definitely could generate a single text node, I'm not sure what the difference is performance-wise between granular updates versus replacing a large chunk of text if only a small part of it has changed. How problematic is it if during enhancement |
I think the general assumption on progressive enhancement is that watching the 'Elements' tab in devtools will not show any flashes while the page is loading. I think google dings you on "render blocking javascript" if the DOM is changed by loading scripts, but I'm not positive. My opinion falls on the side of a few text nodes updating during initial render not being an issue, which is why I still haven't resolved that issue 😄. |
Fixed in Svelte 5 |
The parser generates text nodes either side of comments – they should be concatenated
The text was updated successfully, but these errors were encountered: