salesforce / lwc

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

`disableSyntheticShadowSupport` should allow `<slot>`s to be static-optimized #4351

Open nolanlawson opened 4 months ago

nolanlawson commented 4 months ago

When disableSyntheticShadowSupport=true and enableStaticContentOptimization=true are enabled, and we're compiling a shadow-DOM template, then we should be able to render a <slot> as a regular static-optimizable element rather than a special VNode.

In principle, there's no reason that native shadow DOM can't just render a slot as a <slot>, so it should be safe to static-optimize.

Note that this applies to <slot>s but not the slot attribute. The slot attribute cannot be as easily optimized, because at compile time, we don't know whether it's getting slotted into a light DOM or shadow DOM component:

<x-foo>
  <!-- is x-foo shadow or light? -->
  <div slot="bar"></div>
</x-foo>