Giter Site home page Giter Site logo

Collapse consecutive text nodes about svelte HOT 4 CLOSED

sveltejs avatar sveltejs commented on September 27, 2024 3
Collapse consecutive text nodes

from svelte.

Comments (4)

evs-chris avatar evs-chris commented on September 27, 2024

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.

from svelte.

Rich-Harris avatar Rich-Harris commented on September 27, 2024

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 hello world! changes to hello and gets followed by new text nodes for world and !? It seems like there are always going to be annoying mismatches (comments, inter-element whitespace) between HTML and template, and ideally the enhancer would work around them – but I say that rather glibly, having not been in the trenches during that particular war.

from svelte.

evs-chris avatar evs-chris commented on September 27, 2024

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 😄.

from svelte.

Rich-Harris avatar Rich-Harris commented on September 27, 2024

Fixed in Svelte 5

from svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.