prashantpalikhe / nuxt-ssr-lit

SSR support for Lit elements in Nuxt3
Other
42 stars 7 forks source link

fix: only alter the template for the lit components, nothing else #138

Closed prashantpalikhe closed 2 months ago

prashantpalikhe commented 2 months ago

Ultrahtml has some issues with parsing HTML which is specific DSL of Vue. E.g. a scoped slot template like

<template #someslot="{ someProp }">
  <div>{{ someProp }}</div>
</template>

is rendered incorrectly by the Ultrahtml renderer.

<template ="}"" someProp="">
<div>{{ someProp }}</div>
</template>

Before this PR, we rendered the entire generated AST using Ultrahtml's renderer.

This caused such scoped slots templates to be incorrect after the autoLitWrapper plugin was applied.

With this PR, we now surgically alter only the Lit elements configured to be auto-wrapped. Nothing else. And we do this using magic-string.

This leaves the rest of the template as is. And we do not run into the shortcomings of Ultrahtml.