-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: falsy
f-*
attributes not preserved inside island (#2498)
Fixes #2359
- Loading branch information
1 parent
fba3f2b
commit 2b88f4b
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useSignal } from "@preact/signals"; | ||
import { useEffect } from "preact/hooks"; | ||
|
||
export interface FreshAttrs { | ||
id?: string; | ||
} | ||
|
||
export function FreshAttrs(props: FreshAttrs) { | ||
const active = useSignal(false); | ||
useEffect(() => { | ||
active.value = true; | ||
}, []); | ||
|
||
return ( | ||
<div id={props.id} class={active.value ? "ready" : ""}> | ||
<h1>Fresh attrs</h1> | ||
<div class="f-client-nav-true" f-client-nav={true}>f-client-nav=true</div> | ||
<div class="f-client-nav-false" f-client-nav={false}> | ||
f-client-nav=false | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters