fix(csr): prevent native output recursion
Quality / quality (ubuntu-latest) (push) Failing after 22s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 18:08:35 +05:30
parent 8fa3d7ecd1
commit cf06a60f2b
2 changed files with 26 additions and 0 deletions
+20
View File
@@ -781,6 +781,26 @@ test("development runtime allows an output with no parent binding", () => {
expect(warnings).toHaveLength(0);
});
test("an unbound native-named output does not re-enter its DOM handler", () => {
const win = mount(
`<div data-scope="" data-wrn-events="click">` +
`<button data-on-click="output.click()">go</button>` +
`</div>`,
);
const root = win.document.querySelector("[data-wrn-events]") as unknown as HTMLElement;
let outputs = 0;
root.addEventListener("click", (event) => {
if ((event as Event & { __wrnexusComponentOutput?: boolean }).__wrnexusComponentOutput) {
outputs += 1;
}
});
expect(() =>
(win.document.querySelector("button") as unknown as HTMLElement).click(),
).not.toThrow();
expect(outputs).toBe(1);
});
test("development runtime warns when a component binding names a missing function", () => {
const win = new Window() as unknown as Window & Record<string, unknown>;
win.document.body.innerHTML =