fix: falsy f-* attributes not preserved inside island (#2498)

Fixes https://github.com/denoland/fresh/issues/2359
This commit is contained in:
Marvin Hagemeister
2024-06-05 10:06:53 +02:00
committed by GitHub
parent fba3f2b845
commit 2b88f4bf56
5 changed files with 68 additions and 1 deletions
+1
View File
@@ -1,4 +1,5 @@
import "./polyfills.ts";
import "./preact_hooks_client.ts";
import "./partials.ts";
export { asset, IS_BROWSER, Partial, type PartialProps } from "../shared.ts";
export { boot, revive } from "./reviver.ts";
+11 -1
View File
@@ -1,9 +1,19 @@
import { options } from "preact";
import { assetHashingHook } from "../shared_internal.tsx";
import { assetHashingHook, CLIENT_NAV_ATTR } from "../shared_internal.tsx";
import { BUILD_ID } from "../build_id.ts";
const oldVNodeHook = options.vnode;
options.vnode = (vnode) => {
assetHashingHook(vnode, BUILD_ID);
if (typeof vnode.type === "string") {
if (CLIENT_NAV_ATTR in vnode.props) {
const value = vnode.props[CLIENT_NAV_ATTR];
if (typeof value === "boolean") {
vnode.props[CLIENT_NAV_ATTR] = String(value);
}
}
}
oldVNodeHook?.(vnode);
};