fix(compiler): preserve server-only loader text and control blocks

This commit is contained in:
Clintchiz committed 2026-08-26 12:25:26 +05:30
1 parent aec1dc6056
commit bfa72d5679
4 files changed
+36 -6

No files matched your search

@@ -6,6 +6,9 @@ test("server-only loader data renders native input attributes without client sta
parse(`page Profile {
load server account { return {} }
view {
<h1>{account.name}</h1>
{#if account.readonly}<p>Read only</p>{:else}<p>Editable</p>{/if}
{#each account.items as item}<strong>{item}</strong>{/each}
<input value="{account.name}" readonly="{account.readonly}" />
<select><option value="light" selected="{account.theme === 'light'}">Light</option><option value="dark" selected="{account.theme === 'dark'}">Dark</option></select>
<div data-component="ProfileShell" identity="{account.identity}"></div>
@@ -17,7 +20,13 @@ test("server-only loader data renders native input attributes without client sta
`data:text/javascript;base64,${Buffer.from(javascript).toString("base64")}`
);
const html = await page.default({
account: { name: 'A "<User>"', readonly: false, theme: "dark", identity: { name: "Alice" } },
account: {
items: ["Example record"],
name: 'A "<User>"',
readonly: false,
theme: "dark",
identity: { name: "Alice" },
},
});
expect(html).toContain('value="A &quot;&lt;User&gt;&quot;"');
expect(html).not.toContain(" readonly");
@@ -26,4 +35,10 @@ test("server-only loader data renders native input attributes without client sta
expect(html).toContain('identity="{&quot;name&quot;:&quot;Alice&quot;}"');
expect(html).not.toContain("data-wrn-bind");
expect(html).not.toContain("{account.");
expect(html).toContain("<h1>A &quot;&lt;User&gt;&quot;</h1>");
expect(html).toContain("<p>Editable</p>");
expect(html).toContain("<strong>Example record</strong>");
expect(html).not.toContain("data-wrn-if");
expect(html).not.toContain("data-wrn-each");
expect(html).not.toContain("data-text");
});