salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.64k stars 393 forks source link

[SSR] [engine-server] Non-static-optimized renders ZWJ around HTML comments #4752

Open nolanlawson opened 17 hours ago

nolanlawson commented 17 hours ago

If HTML comments are adjacent to an empty text node and a non-empty text node, and if lwc:preserve-comments is false, then non-static-optimized template HTML will render ZWJ (Zero-Width-Joiner) characters incorrectly.

Repro:

<template>
    <span lwc:spread={fake}>
        {dynamic}<!-- comment -->text<!-- comment -->{dynamic}
    </span>
</template>

Renders:

<x-comments-text>
  <template shadowrootmode="open">
    <span>
      [ZWJ]text[ZWJ]
    </span>
  </template>
</x-comments-text>

(GitHub doesn't render the ZWJ in a way you can easily see, so I marked them above.)

Static-optimized code does not have the same issue. I'm using lwc:spread={fake} above to manually disable the static content optimization.

ZWJ characters are only supposed to be rendered for a single empty text node. Since the HTML above has non-empty text, there should be no ZWJ.

Repro: 319a54634

git2gus[bot] commented 14 hours ago

This issue has been linked to a new work item: W-17110937