fix: unable to opt out of nested client nav (#1940)
This commit is contained in:
@@ -872,8 +872,14 @@ export interface FreshHistoryState {
|
|||||||
scrollY: number;
|
scrollY: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkClientNavEnabled() {
|
function checkClientNavEnabled(el: HTMLElement | null) {
|
||||||
return document.querySelector(`[${CLIENT_NAV_ATTR}]`) !== null;
|
if (el === null) {
|
||||||
|
return document.querySelector(`[${CLIENT_NAV_ATTR}="true"]`) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const setting = el.closest(`[${CLIENT_NAV_ATTR}]`);
|
||||||
|
if (setting === null) return false;
|
||||||
|
return setting.getAttribute(CLIENT_NAV_ATTR) === "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of history state to apply forward or backward animations
|
// Keep track of history state to apply forward or backward animations
|
||||||
@@ -917,8 +923,7 @@ document.addEventListener("click", async (e) => {
|
|||||||
// we're doing a fragment navigation.
|
// we're doing a fragment navigation.
|
||||||
if (
|
if (
|
||||||
el.getAttribute("href")?.startsWith("#") ||
|
el.getAttribute("href")?.startsWith("#") ||
|
||||||
!checkClientNavEnabled() ||
|
!checkClientNavEnabled(el)
|
||||||
el.closest(`[${CLIENT_NAV_ATTR}="true"]`) === null
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -978,8 +983,7 @@ document.addEventListener("click", async (e) => {
|
|||||||
// Check if the user opted out of client side navigation.
|
// Check if the user opted out of client side navigation.
|
||||||
if (
|
if (
|
||||||
partial === null ||
|
partial === null ||
|
||||||
!checkClientNavEnabled() ||
|
!checkClientNavEnabled(button)
|
||||||
button.closest(`[${CLIENT_NAV_ATTR}="true"]`) === null
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1009,7 +1013,7 @@ addEventListener("popstate", async (e) => {
|
|||||||
const nextIdx = state.index ?? index + 1;
|
const nextIdx = state.index ?? index + 1;
|
||||||
index = nextIdx;
|
index = nextIdx;
|
||||||
|
|
||||||
if (!checkClientNavEnabled()) {
|
if (!checkClientNavEnabled(null)) {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ options.vnode = (vnode) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof props[CLIENT_NAV_ATTR] === "boolean") {
|
if (typeof props[CLIENT_NAV_ATTR] === "boolean") {
|
||||||
props[CLIENT_NAV_ATTR] = props[CLIENT_NAV_ATTR] ? "true" : null;
|
props[CLIENT_NAV_ATTR] = props[CLIENT_NAV_ATTR] ? "true" : "false";
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
current && typeof vnode.type === "function" && vnode.type !== Fragment &&
|
current && typeof vnode.type === "function" && vnode.type !== Fragment &&
|
||||||
|
|||||||
+152
-142
@@ -20,77 +20,82 @@ import * as $14 from "./routes/client_nav/injected.tsx";
|
|||||||
import * as $15 from "./routes/client_nav/page-a.tsx";
|
import * as $15 from "./routes/client_nav/page-a.tsx";
|
||||||
import * as $16 from "./routes/client_nav/page-b.tsx";
|
import * as $16 from "./routes/client_nav/page-b.tsx";
|
||||||
import * as $17 from "./routes/client_nav/page-c.tsx";
|
import * as $17 from "./routes/client_nav/page-c.tsx";
|
||||||
import * as $18 from "./routes/client_nav_opt_out/_layout.tsx";
|
import * as $18 from "./routes/client_nav_both/_layout.tsx";
|
||||||
import * as $19 from "./routes/client_nav_opt_out/index.tsx";
|
import * as $19 from "./routes/client_nav_both/index.tsx";
|
||||||
import * as $20 from "./routes/client_nav_opt_out/injected.tsx";
|
import * as $20 from "./routes/client_nav_both/page-a.tsx";
|
||||||
import * as $21 from "./routes/client_nav_opt_out/page-a.tsx";
|
import * as $21 from "./routes/client_nav_both/page-b.tsx";
|
||||||
import * as $22 from "./routes/client_nav_opt_out/page-b.tsx";
|
import * as $22 from "./routes/client_nav_both/page-c.tsx";
|
||||||
import * as $23 from "./routes/client_nav_opt_out/page-c.tsx";
|
import * as $23 from "./routes/client_nav_opt_out/_layout.tsx";
|
||||||
import * as $24 from "./routes/deep_partial/index.tsx";
|
import * as $24 from "./routes/client_nav_opt_out/index.tsx";
|
||||||
import * as $25 from "./routes/deep_partial/injected.tsx";
|
import * as $25 from "./routes/client_nav_opt_out/injected.tsx";
|
||||||
import * as $26 from "./routes/deep_partial/update.tsx";
|
import * as $26 from "./routes/client_nav_opt_out/page-a.tsx";
|
||||||
import * as $27 from "./routes/form/index.tsx";
|
import * as $27 from "./routes/client_nav_opt_out/page-b.tsx";
|
||||||
import * as $28 from "./routes/form/injected.tsx";
|
import * as $28 from "./routes/client_nav_opt_out/page-c.tsx";
|
||||||
import * as $29 from "./routes/form/update.tsx";
|
import * as $29 from "./routes/deep_partial/index.tsx";
|
||||||
import * as $30 from "./routes/fragment_nav.tsx";
|
import * as $30 from "./routes/deep_partial/injected.tsx";
|
||||||
import * as $31 from "./routes/fragment_nav_scroll.tsx";
|
import * as $31 from "./routes/deep_partial/update.tsx";
|
||||||
import * as $32 from "./routes/head_merge/duplicate.tsx";
|
import * as $32 from "./routes/form/index.tsx";
|
||||||
import * as $33 from "./routes/head_merge/index.tsx";
|
import * as $33 from "./routes/form/injected.tsx";
|
||||||
import * as $34 from "./routes/head_merge/injected.tsx";
|
import * as $34 from "./routes/form/update.tsx";
|
||||||
import * as $35 from "./routes/head_merge/update.tsx";
|
import * as $35 from "./routes/fragment_nav.tsx";
|
||||||
import * as $36 from "./routes/index.tsx";
|
import * as $36 from "./routes/fragment_nav_scroll.tsx";
|
||||||
import * as $37 from "./routes/island_instance/index.tsx";
|
import * as $37 from "./routes/head_merge/duplicate.tsx";
|
||||||
import * as $38 from "./routes/island_instance/injected.tsx";
|
import * as $38 from "./routes/head_merge/index.tsx";
|
||||||
import * as $39 from "./routes/island_instance/partial.tsx";
|
import * as $39 from "./routes/head_merge/injected.tsx";
|
||||||
import * as $40 from "./routes/island_instance/partial_remove.tsx";
|
import * as $40 from "./routes/head_merge/update.tsx";
|
||||||
import * as $41 from "./routes/island_instance/partial_replace.tsx";
|
import * as $41 from "./routes/index.tsx";
|
||||||
import * as $42 from "./routes/island_instance_multiple/index.tsx";
|
import * as $42 from "./routes/island_instance/index.tsx";
|
||||||
import * as $43 from "./routes/island_instance_multiple/injected.tsx";
|
import * as $43 from "./routes/island_instance/injected.tsx";
|
||||||
import * as $44 from "./routes/island_instance_multiple/partial.tsx";
|
import * as $44 from "./routes/island_instance/partial.tsx";
|
||||||
import * as $45 from "./routes/island_instance_multiple/partial_both.tsx";
|
import * as $45 from "./routes/island_instance/partial_remove.tsx";
|
||||||
import * as $46 from "./routes/island_instance_nested/index.tsx";
|
import * as $46 from "./routes/island_instance/partial_replace.tsx";
|
||||||
import * as $47 from "./routes/island_instance_nested/injected.tsx";
|
import * as $47 from "./routes/island_instance_multiple/index.tsx";
|
||||||
import * as $48 from "./routes/island_instance_nested/partial.tsx";
|
import * as $48 from "./routes/island_instance_multiple/injected.tsx";
|
||||||
import * as $49 from "./routes/island_instance_nested/replace.tsx";
|
import * as $49 from "./routes/island_instance_multiple/partial.tsx";
|
||||||
import * as $50 from "./routes/island_props/index.tsx";
|
import * as $50 from "./routes/island_instance_multiple/partial_both.tsx";
|
||||||
import * as $51 from "./routes/island_props/injected.tsx";
|
import * as $51 from "./routes/island_instance_nested/index.tsx";
|
||||||
import * as $52 from "./routes/island_props/partial.tsx";
|
import * as $52 from "./routes/island_instance_nested/injected.tsx";
|
||||||
import * as $53 from "./routes/island_props_signals/index.tsx";
|
import * as $53 from "./routes/island_instance_nested/partial.tsx";
|
||||||
import * as $54 from "./routes/island_props_signals/injected.tsx";
|
import * as $54 from "./routes/island_instance_nested/replace.tsx";
|
||||||
import * as $55 from "./routes/island_props_signals/partial.tsx";
|
import * as $55 from "./routes/island_props/index.tsx";
|
||||||
import * as $56 from "./routes/keys/index.tsx";
|
import * as $56 from "./routes/island_props/injected.tsx";
|
||||||
import * as $57 from "./routes/keys/injected.tsx";
|
import * as $57 from "./routes/island_props/partial.tsx";
|
||||||
import * as $58 from "./routes/keys/swap.tsx";
|
import * as $58 from "./routes/island_props_signals/index.tsx";
|
||||||
import * as $59 from "./routes/keys_components/index.tsx";
|
import * as $59 from "./routes/island_props_signals/injected.tsx";
|
||||||
import * as $60 from "./routes/keys_components/injected.tsx";
|
import * as $60 from "./routes/island_props_signals/partial.tsx";
|
||||||
import * as $61 from "./routes/keys_components/swap.tsx";
|
import * as $61 from "./routes/keys/index.tsx";
|
||||||
import * as $62 from "./routes/keys_confusion/index.tsx";
|
import * as $62 from "./routes/keys/injected.tsx";
|
||||||
import * as $63 from "./routes/keys_dom/index.tsx";
|
import * as $63 from "./routes/keys/swap.tsx";
|
||||||
import * as $64 from "./routes/keys_dom/injected.tsx";
|
import * as $64 from "./routes/keys_components/index.tsx";
|
||||||
import * as $65 from "./routes/keys_dom/swap.tsx";
|
import * as $65 from "./routes/keys_components/injected.tsx";
|
||||||
import * as $66 from "./routes/keys_outside/index.tsx";
|
import * as $66 from "./routes/keys_components/swap.tsx";
|
||||||
import * as $67 from "./routes/loading/index.tsx";
|
import * as $67 from "./routes/keys_confusion/index.tsx";
|
||||||
import * as $68 from "./routes/loading/injected.tsx";
|
import * as $68 from "./routes/keys_dom/index.tsx";
|
||||||
import * as $69 from "./routes/loading/update.tsx";
|
import * as $69 from "./routes/keys_dom/injected.tsx";
|
||||||
import * as $70 from "./routes/missing_partial/index.tsx";
|
import * as $70 from "./routes/keys_dom/swap.tsx";
|
||||||
import * as $71 from "./routes/missing_partial/injected.tsx";
|
import * as $71 from "./routes/keys_outside/index.tsx";
|
||||||
import * as $72 from "./routes/missing_partial/update.tsx";
|
import * as $72 from "./routes/loading/index.tsx";
|
||||||
import * as $73 from "./routes/mode/append.tsx";
|
import * as $73 from "./routes/loading/injected.tsx";
|
||||||
import * as $74 from "./routes/mode/index.tsx";
|
import * as $74 from "./routes/loading/update.tsx";
|
||||||
import * as $75 from "./routes/mode/injected.tsx";
|
import * as $75 from "./routes/missing_partial/index.tsx";
|
||||||
import * as $76 from "./routes/mode/prepend.tsx";
|
import * as $76 from "./routes/missing_partial/injected.tsx";
|
||||||
import * as $77 from "./routes/mode/replace.tsx";
|
import * as $77 from "./routes/missing_partial/update.tsx";
|
||||||
import * as $78 from "./routes/no_islands/index.tsx";
|
import * as $78 from "./routes/mode/append.tsx";
|
||||||
import * as $79 from "./routes/no_islands/injected.tsx";
|
import * as $79 from "./routes/mode/index.tsx";
|
||||||
import * as $80 from "./routes/no_islands/update.tsx";
|
import * as $80 from "./routes/mode/injected.tsx";
|
||||||
import * as $81 from "./routes/no_partial_response/index.tsx";
|
import * as $81 from "./routes/mode/prepend.tsx";
|
||||||
import * as $82 from "./routes/no_partial_response/injected.tsx";
|
import * as $82 from "./routes/mode/replace.tsx";
|
||||||
import * as $83 from "./routes/no_partial_response/update.tsx";
|
import * as $83 from "./routes/no_islands/index.tsx";
|
||||||
import * as $84 from "./routes/partial_slot_inside_island.tsx";
|
import * as $84 from "./routes/no_islands/injected.tsx";
|
||||||
import * as $85 from "./routes/relative_link/index.tsx";
|
import * as $85 from "./routes/no_islands/update.tsx";
|
||||||
import * as $86 from "./routes/scroll_restoration/index.tsx";
|
import * as $86 from "./routes/no_partial_response/index.tsx";
|
||||||
import * as $87 from "./routes/scroll_restoration/injected.tsx";
|
import * as $87 from "./routes/no_partial_response/injected.tsx";
|
||||||
import * as $88 from "./routes/scroll_restoration/update.tsx";
|
import * as $88 from "./routes/no_partial_response/update.tsx";
|
||||||
|
import * as $89 from "./routes/partial_slot_inside_island.tsx";
|
||||||
|
import * as $90 from "./routes/relative_link/index.tsx";
|
||||||
|
import * as $91 from "./routes/scroll_restoration/index.tsx";
|
||||||
|
import * as $92 from "./routes/scroll_restoration/injected.tsx";
|
||||||
|
import * as $93 from "./routes/scroll_restoration/update.tsx";
|
||||||
import * as $$0 from "./islands/Counter.tsx";
|
import * as $$0 from "./islands/Counter.tsx";
|
||||||
import * as $$1 from "./islands/CounterA.tsx";
|
import * as $$1 from "./islands/CounterA.tsx";
|
||||||
import * as $$2 from "./islands/CounterB.tsx";
|
import * as $$2 from "./islands/CounterB.tsx";
|
||||||
@@ -127,77 +132,82 @@ const manifest = {
|
|||||||
"./routes/client_nav/page-a.tsx": $15,
|
"./routes/client_nav/page-a.tsx": $15,
|
||||||
"./routes/client_nav/page-b.tsx": $16,
|
"./routes/client_nav/page-b.tsx": $16,
|
||||||
"./routes/client_nav/page-c.tsx": $17,
|
"./routes/client_nav/page-c.tsx": $17,
|
||||||
"./routes/client_nav_opt_out/_layout.tsx": $18,
|
"./routes/client_nav_both/_layout.tsx": $18,
|
||||||
"./routes/client_nav_opt_out/index.tsx": $19,
|
"./routes/client_nav_both/index.tsx": $19,
|
||||||
"./routes/client_nav_opt_out/injected.tsx": $20,
|
"./routes/client_nav_both/page-a.tsx": $20,
|
||||||
"./routes/client_nav_opt_out/page-a.tsx": $21,
|
"./routes/client_nav_both/page-b.tsx": $21,
|
||||||
"./routes/client_nav_opt_out/page-b.tsx": $22,
|
"./routes/client_nav_both/page-c.tsx": $22,
|
||||||
"./routes/client_nav_opt_out/page-c.tsx": $23,
|
"./routes/client_nav_opt_out/_layout.tsx": $23,
|
||||||
"./routes/deep_partial/index.tsx": $24,
|
"./routes/client_nav_opt_out/index.tsx": $24,
|
||||||
"./routes/deep_partial/injected.tsx": $25,
|
"./routes/client_nav_opt_out/injected.tsx": $25,
|
||||||
"./routes/deep_partial/update.tsx": $26,
|
"./routes/client_nav_opt_out/page-a.tsx": $26,
|
||||||
"./routes/form/index.tsx": $27,
|
"./routes/client_nav_opt_out/page-b.tsx": $27,
|
||||||
"./routes/form/injected.tsx": $28,
|
"./routes/client_nav_opt_out/page-c.tsx": $28,
|
||||||
"./routes/form/update.tsx": $29,
|
"./routes/deep_partial/index.tsx": $29,
|
||||||
"./routes/fragment_nav.tsx": $30,
|
"./routes/deep_partial/injected.tsx": $30,
|
||||||
"./routes/fragment_nav_scroll.tsx": $31,
|
"./routes/deep_partial/update.tsx": $31,
|
||||||
"./routes/head_merge/duplicate.tsx": $32,
|
"./routes/form/index.tsx": $32,
|
||||||
"./routes/head_merge/index.tsx": $33,
|
"./routes/form/injected.tsx": $33,
|
||||||
"./routes/head_merge/injected.tsx": $34,
|
"./routes/form/update.tsx": $34,
|
||||||
"./routes/head_merge/update.tsx": $35,
|
"./routes/fragment_nav.tsx": $35,
|
||||||
"./routes/index.tsx": $36,
|
"./routes/fragment_nav_scroll.tsx": $36,
|
||||||
"./routes/island_instance/index.tsx": $37,
|
"./routes/head_merge/duplicate.tsx": $37,
|
||||||
"./routes/island_instance/injected.tsx": $38,
|
"./routes/head_merge/index.tsx": $38,
|
||||||
"./routes/island_instance/partial.tsx": $39,
|
"./routes/head_merge/injected.tsx": $39,
|
||||||
"./routes/island_instance/partial_remove.tsx": $40,
|
"./routes/head_merge/update.tsx": $40,
|
||||||
"./routes/island_instance/partial_replace.tsx": $41,
|
"./routes/index.tsx": $41,
|
||||||
"./routes/island_instance_multiple/index.tsx": $42,
|
"./routes/island_instance/index.tsx": $42,
|
||||||
"./routes/island_instance_multiple/injected.tsx": $43,
|
"./routes/island_instance/injected.tsx": $43,
|
||||||
"./routes/island_instance_multiple/partial.tsx": $44,
|
"./routes/island_instance/partial.tsx": $44,
|
||||||
"./routes/island_instance_multiple/partial_both.tsx": $45,
|
"./routes/island_instance/partial_remove.tsx": $45,
|
||||||
"./routes/island_instance_nested/index.tsx": $46,
|
"./routes/island_instance/partial_replace.tsx": $46,
|
||||||
"./routes/island_instance_nested/injected.tsx": $47,
|
"./routes/island_instance_multiple/index.tsx": $47,
|
||||||
"./routes/island_instance_nested/partial.tsx": $48,
|
"./routes/island_instance_multiple/injected.tsx": $48,
|
||||||
"./routes/island_instance_nested/replace.tsx": $49,
|
"./routes/island_instance_multiple/partial.tsx": $49,
|
||||||
"./routes/island_props/index.tsx": $50,
|
"./routes/island_instance_multiple/partial_both.tsx": $50,
|
||||||
"./routes/island_props/injected.tsx": $51,
|
"./routes/island_instance_nested/index.tsx": $51,
|
||||||
"./routes/island_props/partial.tsx": $52,
|
"./routes/island_instance_nested/injected.tsx": $52,
|
||||||
"./routes/island_props_signals/index.tsx": $53,
|
"./routes/island_instance_nested/partial.tsx": $53,
|
||||||
"./routes/island_props_signals/injected.tsx": $54,
|
"./routes/island_instance_nested/replace.tsx": $54,
|
||||||
"./routes/island_props_signals/partial.tsx": $55,
|
"./routes/island_props/index.tsx": $55,
|
||||||
"./routes/keys/index.tsx": $56,
|
"./routes/island_props/injected.tsx": $56,
|
||||||
"./routes/keys/injected.tsx": $57,
|
"./routes/island_props/partial.tsx": $57,
|
||||||
"./routes/keys/swap.tsx": $58,
|
"./routes/island_props_signals/index.tsx": $58,
|
||||||
"./routes/keys_components/index.tsx": $59,
|
"./routes/island_props_signals/injected.tsx": $59,
|
||||||
"./routes/keys_components/injected.tsx": $60,
|
"./routes/island_props_signals/partial.tsx": $60,
|
||||||
"./routes/keys_components/swap.tsx": $61,
|
"./routes/keys/index.tsx": $61,
|
||||||
"./routes/keys_confusion/index.tsx": $62,
|
"./routes/keys/injected.tsx": $62,
|
||||||
"./routes/keys_dom/index.tsx": $63,
|
"./routes/keys/swap.tsx": $63,
|
||||||
"./routes/keys_dom/injected.tsx": $64,
|
"./routes/keys_components/index.tsx": $64,
|
||||||
"./routes/keys_dom/swap.tsx": $65,
|
"./routes/keys_components/injected.tsx": $65,
|
||||||
"./routes/keys_outside/index.tsx": $66,
|
"./routes/keys_components/swap.tsx": $66,
|
||||||
"./routes/loading/index.tsx": $67,
|
"./routes/keys_confusion/index.tsx": $67,
|
||||||
"./routes/loading/injected.tsx": $68,
|
"./routes/keys_dom/index.tsx": $68,
|
||||||
"./routes/loading/update.tsx": $69,
|
"./routes/keys_dom/injected.tsx": $69,
|
||||||
"./routes/missing_partial/index.tsx": $70,
|
"./routes/keys_dom/swap.tsx": $70,
|
||||||
"./routes/missing_partial/injected.tsx": $71,
|
"./routes/keys_outside/index.tsx": $71,
|
||||||
"./routes/missing_partial/update.tsx": $72,
|
"./routes/loading/index.tsx": $72,
|
||||||
"./routes/mode/append.tsx": $73,
|
"./routes/loading/injected.tsx": $73,
|
||||||
"./routes/mode/index.tsx": $74,
|
"./routes/loading/update.tsx": $74,
|
||||||
"./routes/mode/injected.tsx": $75,
|
"./routes/missing_partial/index.tsx": $75,
|
||||||
"./routes/mode/prepend.tsx": $76,
|
"./routes/missing_partial/injected.tsx": $76,
|
||||||
"./routes/mode/replace.tsx": $77,
|
"./routes/missing_partial/update.tsx": $77,
|
||||||
"./routes/no_islands/index.tsx": $78,
|
"./routes/mode/append.tsx": $78,
|
||||||
"./routes/no_islands/injected.tsx": $79,
|
"./routes/mode/index.tsx": $79,
|
||||||
"./routes/no_islands/update.tsx": $80,
|
"./routes/mode/injected.tsx": $80,
|
||||||
"./routes/no_partial_response/index.tsx": $81,
|
"./routes/mode/prepend.tsx": $81,
|
||||||
"./routes/no_partial_response/injected.tsx": $82,
|
"./routes/mode/replace.tsx": $82,
|
||||||
"./routes/no_partial_response/update.tsx": $83,
|
"./routes/no_islands/index.tsx": $83,
|
||||||
"./routes/partial_slot_inside_island.tsx": $84,
|
"./routes/no_islands/injected.tsx": $84,
|
||||||
"./routes/relative_link/index.tsx": $85,
|
"./routes/no_islands/update.tsx": $85,
|
||||||
"./routes/scroll_restoration/index.tsx": $86,
|
"./routes/no_partial_response/index.tsx": $86,
|
||||||
"./routes/scroll_restoration/injected.tsx": $87,
|
"./routes/no_partial_response/injected.tsx": $87,
|
||||||
"./routes/scroll_restoration/update.tsx": $88,
|
"./routes/no_partial_response/update.tsx": $88,
|
||||||
|
"./routes/partial_slot_inside_island.tsx": $89,
|
||||||
|
"./routes/relative_link/index.tsx": $90,
|
||||||
|
"./routes/scroll_restoration/index.tsx": $91,
|
||||||
|
"./routes/scroll_restoration/injected.tsx": $92,
|
||||||
|
"./routes/scroll_restoration/update.tsx": $93,
|
||||||
},
|
},
|
||||||
islands: {
|
islands: {
|
||||||
"./islands/Counter.tsx": $$0,
|
"./islands/Counter.tsx": $$0,
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { AppProps } from "$fresh/server.ts";
|
||||||
|
import { Partial } from "$fresh/runtime.ts";
|
||||||
|
import { Fader } from "../../islands/Fader.tsx";
|
||||||
|
|
||||||
|
export default function AppLayout({ Component }: AppProps) {
|
||||||
|
return (
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>fresh title</title>
|
||||||
|
</head>
|
||||||
|
<body f-client-nav>
|
||||||
|
<Partial name="body">
|
||||||
|
<Fader>
|
||||||
|
<Component />
|
||||||
|
</Fader>
|
||||||
|
</Partial>
|
||||||
|
<div f-client-nav={false}>
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
class="page-a-link"
|
||||||
|
href="/client_nav_both/page-a"
|
||||||
|
>
|
||||||
|
Page A
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
class="page-b-link"
|
||||||
|
href="/client_nav_both/page-b"
|
||||||
|
>
|
||||||
|
Page B
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
class="page-c-link"
|
||||||
|
href="/client_nav_both/page-c"
|
||||||
|
>
|
||||||
|
Page C
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<pre id="logs" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Partial } from "$fresh/runtime.ts";
|
||||||
|
import { RouteConfig } from "$fresh/server.ts";
|
||||||
|
import CounterA from "../../islands/CounterA.tsx";
|
||||||
|
import { Fader } from "../../islands/Fader.tsx";
|
||||||
|
|
||||||
|
export const config: RouteConfig = {
|
||||||
|
skipAppWrapper: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ModeDemo() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Partial name="slot-1">
|
||||||
|
<Fader>
|
||||||
|
<p class="status-initial">Initial content</p>
|
||||||
|
<CounterA />
|
||||||
|
</Fader>
|
||||||
|
</Partial>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { RouteConfig } from "$fresh/server.ts";
|
||||||
|
import CounterA from "../../islands/CounterA.tsx";
|
||||||
|
import { Fader } from "../../islands/Fader.tsx";
|
||||||
|
|
||||||
|
export const config: RouteConfig = {
|
||||||
|
skipAppWrapper: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function PageA() {
|
||||||
|
return (
|
||||||
|
<Fader>
|
||||||
|
<h1>Page A</h1>
|
||||||
|
<p>asdfasdf asdf asdf</p>
|
||||||
|
<CounterA />
|
||||||
|
</Fader>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { RouteConfig } from "$fresh/server.ts";
|
||||||
|
import { Fader } from "../../islands/Fader.tsx";
|
||||||
|
import CounterB from "../../islands/CounterB.tsx";
|
||||||
|
|
||||||
|
export const config: RouteConfig = {
|
||||||
|
skipAppWrapper: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function PageB() {
|
||||||
|
return (
|
||||||
|
<Fader>
|
||||||
|
<i>something before</i>
|
||||||
|
<div>
|
||||||
|
<h1>Page B</h1>
|
||||||
|
</div>
|
||||||
|
<CounterB />
|
||||||
|
<p>asdfasdf asdf asdf</p>
|
||||||
|
</Fader>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { RouteConfig } from "$fresh/server.ts";
|
||||||
|
import { Fader } from "../../islands/Fader.tsx";
|
||||||
|
|
||||||
|
export const config: RouteConfig = {
|
||||||
|
skipAppWrapper: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function PageB() {
|
||||||
|
return (
|
||||||
|
<Fader>
|
||||||
|
<h1>Page C</h1>
|
||||||
|
<span class="page-c-text">
|
||||||
|
<p>asdfasdf asdf asdf</p>
|
||||||
|
</span>
|
||||||
|
</Fader>
|
||||||
|
);
|
||||||
|
}
|
||||||
+58
-1
@@ -15,7 +15,8 @@ import {
|
|||||||
} from "./test_utils.ts";
|
} from "./test_utils.ts";
|
||||||
|
|
||||||
async function assertLogs(page: Page, expected: string[]) {
|
async function assertLogs(page: Page, expected: string[]) {
|
||||||
await waitForText(page, "#logs", expected.join("\n") + "\n");
|
const text = expected.length > 0 ? expected.join("\n") + "\n" : "";
|
||||||
|
await waitForText(page, "#logs", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.test("injects server content with no islands present", async () => {
|
Deno.test("injects server content with no islands present", async () => {
|
||||||
@@ -852,6 +853,62 @@ Deno.test("allow opting out of client navigation", async () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("allow opting out of client navigation if parent opted in", async () => {
|
||||||
|
await withPageName(
|
||||||
|
"./tests/fixture_partials/main.ts",
|
||||||
|
async (page, address) => {
|
||||||
|
const initialUrl = `${address}/client_nav_both`;
|
||||||
|
await page.goto(initialUrl);
|
||||||
|
await page.waitForSelector(".island");
|
||||||
|
|
||||||
|
await page.click(".island-a button");
|
||||||
|
await waitForText(page, ".output-a", "1");
|
||||||
|
|
||||||
|
// Go to page B
|
||||||
|
await page.click(".page-b-link");
|
||||||
|
await page.waitForSelector(".island-b");
|
||||||
|
await assertLogs(page, ["mount Counter B"]);
|
||||||
|
|
||||||
|
await page.click(".island-b button");
|
||||||
|
await waitForText(page, ".output-b", "1");
|
||||||
|
await assertLogs(page, ["mount Counter B", "update Counter B"]);
|
||||||
|
|
||||||
|
// Go to page C
|
||||||
|
await page.click(".page-c-link");
|
||||||
|
await page.waitForSelector(".page-c-text");
|
||||||
|
await assertLogs(page, []);
|
||||||
|
|
||||||
|
// Go back to B
|
||||||
|
await page.goBack();
|
||||||
|
await page.waitForSelector(".island-b");
|
||||||
|
await assertLogs(page, ["mount Counter B"]);
|
||||||
|
|
||||||
|
// Check that island is interactive
|
||||||
|
await page.click(".island-b button");
|
||||||
|
await waitForText(page, ".output-b", "1");
|
||||||
|
|
||||||
|
// Go back to A
|
||||||
|
await page.goBack();
|
||||||
|
await page.waitForSelector(".island-a");
|
||||||
|
await assertLogs(page, ["mount Counter A"]);
|
||||||
|
|
||||||
|
// Check that island is interactive
|
||||||
|
await page.click(".island-a button");
|
||||||
|
await waitForText(page, ".output-a", "1");
|
||||||
|
await assertNoPageComments(page);
|
||||||
|
|
||||||
|
// Go forward to B
|
||||||
|
await page.goForward();
|
||||||
|
await page.waitForSelector(".island-b");
|
||||||
|
await assertLogs(page, ["mount Counter B"]);
|
||||||
|
|
||||||
|
// Check that island is interactive
|
||||||
|
await page.click(".island-b button");
|
||||||
|
await waitForText(page, ".output-b", "1");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
Deno.test("restore scroll position", async () => {
|
Deno.test("restore scroll position", async () => {
|
||||||
await withPageName(
|
await withPageName(
|
||||||
"./tests/fixture_partials/main.ts",
|
"./tests/fixture_partials/main.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user