-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Description
empty templates result in <?> in the html which is an invalid tag... it can break parsing (at least it breaks sax-wasm)
Steps to Reproduce
- Write this code
const template = ({ title, lang }) => html`
<p>${title}</p>
${html``}
${''}
<p>more</p>
`;
const ssrResult = render(template({ title: "hello", lang: 'en' }));
/***** HELPERS */
const stream = Readable.from(ssrResult);
const ssrString = await streamToString(stream);
console.log(ssrString);
function streamToString(stream) {
const chunks = [];
return new Promise((resolve, reject) => {
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
stream.on("error", (err) => reject(err));
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
});
}execute it via node
Expected Results
no invalid tags in the html
<!--lit-part cI7PGs8mxHY=-->
<p><!--lit-part-->hello<!--/lit-part--></p>
<!--lit-part BRUAAAUVAAA=--><!--/lit-part-->
<!--lit-part--><!--/lit-part-->
<p>more</p>
<!--/lit-part-->Actual Results
the empty template literal has <?> as content
<!--lit-part cI7PGs8mxHY=-->
<p><!--lit-part-->hello<!--/lit-part--></p>
<!--lit-part BRUAAAUVAAA=--><?><!--/lit-part-->
<!--lit-part--><!--/lit-part-->
<p>more</p>
<!--/lit-part-->Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Done