fix theme navigation and improve project scaffolding
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/csr",
|
||||
"version": "0.2.12",
|
||||
"version": "0.2.13",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -65,6 +65,7 @@ export const NAV_RUNTIME = String.raw`
|
||||
try { if (window.__wrnexusHydrateScopes) window.__wrnexusHydrateScopes(document); } catch (e) {}
|
||||
try { if (window.__wrnexusHydrateCsrFetches) window.__wrnexusHydrateCsrFetches(document); } catch (e) {}
|
||||
try { if (window.__wireValidate) window.__wireValidate.init(document); } catch (e) {}
|
||||
try { if (window.wireTheme) window.wireTheme.bind(document); } catch (e) {}
|
||||
}
|
||||
|
||||
function render(html, url, isPop) {
|
||||
|
||||
@@ -91,3 +91,16 @@ test("exposes programmatic navigation", async () => {
|
||||
expect(fetchCalls.length).toBe(1);
|
||||
expect(win.document.getElementById("app").innerHTML).toContain("Dashboard");
|
||||
});
|
||||
|
||||
test("rebinds theme controls after swapping the page", async () => {
|
||||
install(`<div id="app"><a href="/about" id="lnk">About</a></div>`);
|
||||
let boundRoot: unknown;
|
||||
win.wireTheme = { bind: (root: unknown) => (boundRoot = root) };
|
||||
nextHtml = `<html><body><div id="app"><button data-wire-theme-toggle>Theme</button></div></body></html>`;
|
||||
|
||||
win.document.getElementById("lnk").click();
|
||||
await flush();
|
||||
|
||||
expect(boundRoot).toBe(win.document);
|
||||
expect(win.document.querySelector("[data-wire-theme-toggle]")).not.toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user