feat: make state-based attributes reactive
This commit is contained in:
@@ -128,6 +128,23 @@ test("data-show toggles visibility on a reactive expression (tabs pattern)", ()
|
||||
expect(disp("b")).toBe("");
|
||||
});
|
||||
|
||||
test("reactive attribute bindings update input and accessibility attributes", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="show: false">
|
||||
<input id="password" type="password" data-wrn-bind-0='["type","{show ? 'text' : 'password'}"]'>
|
||||
<button data-on-click="show = !show" aria-label="Show password"
|
||||
data-wrn-bind-0='["aria-label","{show ? 'Hide password' : 'Show password'}"]'>Toggle</button>
|
||||
</div>`,
|
||||
);
|
||||
const input = win.document.getElementById("password") as unknown as HTMLInputElement;
|
||||
const button = win.document.querySelector("button") as unknown as HTMLElement;
|
||||
expect(input.type).toBe("password");
|
||||
expect(button.getAttribute("aria-label")).toBe("Show password");
|
||||
button.click();
|
||||
expect(input.type).toBe("text");
|
||||
expect(button.getAttribute("aria-label")).toBe("Hide password");
|
||||
});
|
||||
|
||||
test("independent signals in one scope update correctly (dependency tracking)", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="a: 0, b: 100">
|
||||
|
||||
Reference in New Issue
Block a user