sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.78k stars 4.23k forks source link

SSR/DOM rendering discrepancy #1686

Closed Rich-Harris closed 7 months ago

Rich-Harris commented 6 years ago

Here's a fun one. Svelte won't let you write malformed markup like this...

<p>
  <div>you can't have a div inside a p</div>
</p>

But you can have a component inside the <p> element that has a <div>, or any other element that causes <p> to auto-close.

So in the example in the REPL above, the following markup gets generated...

<p><div>some text</div></p>

...which gets corrected by the browser's HTML parser to this...

<p></p>
<div>some text</div>
<p></p>

...until the client-side renderer takes over, at which point it becomes this again:

<p><div>some text</div></p>

This can cause some hard-to-diagnose flashes of glitchy content. I'm not sure what to do about this. Perhaps if the compiler had a birds-eye view of the component graph, it could respond accordingly.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Rich-Harris commented 7 months ago

fixed in Svelte 5