fix(csr): consume document binding metadata
This commit is contained in:
@@ -549,6 +549,25 @@ test("hydration consumes private scope, behavior, and binding metadata", () => {
|
||||
expect(button.getAttribute("aria-expanded")).toBe("true");
|
||||
});
|
||||
|
||||
test("hydration removes server-resolved document binding metadata", () => {
|
||||
const win = mount(`<main>Document content</main>`);
|
||||
const root = win.document.documentElement;
|
||||
root.setAttribute("lang", "en");
|
||||
root.setAttribute("data-theme", "dark");
|
||||
root.setAttribute("data-wrn-bind-0", '["lang","{language}"]');
|
||||
root.setAttribute("data-wrn-bind-1", '["data-theme","{theme}"]');
|
||||
|
||||
const runtime = win as unknown as {
|
||||
__wrnexusHydrateScopes?: (root: unknown) => void;
|
||||
};
|
||||
runtime.__wrnexusHydrateScopes?.(win.document);
|
||||
|
||||
expect(root.getAttribute("lang")).toBe("en");
|
||||
expect(root.getAttribute("data-theme")).toBe("dark");
|
||||
expect(root.hasAttribute("data-wrn-bind-0")).toBe(false);
|
||||
expect(root.hasAttribute("data-wrn-bind-1")).toBe(false);
|
||||
});
|
||||
|
||||
test("compiled client functions are not overwritten by fallback behavior parsing", () => {
|
||||
const behavior = Buffer.from(
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user