feat: make state-based attributes reactive
This commit is contained in:
@@ -116,6 +116,20 @@ test("page state text bakes its initial value into a reactive data-text span", (
|
||||
expect(page).toContain("data-scope"); // state still forces a reactive scope
|
||||
});
|
||||
|
||||
test("page state attributes bake their initial value and retain a reactive binding", () => {
|
||||
const page = compileWireFile(`page Password {
|
||||
state show = false
|
||||
view {
|
||||
<input type="{show ? 'text' : 'password'}" aria-label="{show ? 'Hide' : 'Show'}">
|
||||
<button @click="show = !show">Toggle</button>
|
||||
}
|
||||
}`);
|
||||
expect(page).toContain('type="password"');
|
||||
expect(page).toContain('aria-label="Show"');
|
||||
expect(page.match(/data-wrn-bind-/g)).toHaveLength(2);
|
||||
expect(page).toContain("show ? 'text' : 'password'");
|
||||
});
|
||||
|
||||
test("data-for: loop-variable mustaches stay literal (not baked server-side)", () => {
|
||||
const comp = compileWireFile(
|
||||
`component TodoList {\n state todos = []\n view { <ul><li data-for="t in todos">{t.text}</li></ul> }\n}`,
|
||||
|
||||
Reference in New Issue
Block a user