fix: Partial state deserialization on simple islands (#1873)

This commit is contained in:
Tiago Gimenes
2023-10-07 23:08:04 +02:00
committed by GitHub
parent 2df5921b59
commit 15f869715c
3 changed files with 20 additions and 23 deletions
+4 -2
View File
@@ -698,8 +698,10 @@ export async function applyPartials(res: Response): Promise<void> {
await Promise.all(promises);
if (deserialize) {
state = deserialize(stateDom!, signal) as SerializedState;
if (stateDom) {
state = deserialize
? deserialize(stateDom, signal) as SerializedState
: JSON.parse(stateDom)?.v;
}
// Collect all partials and build up the vnode tree
@@ -1,21 +1,18 @@
import { Partial } from "$fresh/runtime.ts";
import { Fader } from "../../islands/Fader.tsx";
import PropIsland from "../../islands/PropIsland.tsx";
export default function PropsDemo() {
return (
<div>
<Partial name="slot-1">
<Fader>
<p class="status-initial">initial</p>
<PropIsland
boolean={true}
number={1}
obj={{ foo: 123 }}
strArr={["foo"]}
string="foo"
/>
</Fader>
<p class="status-initial">initial</p>
<PropIsland
boolean={true}
number={1}
obj={{ foo: 123 }}
strArr={["foo"]}
string="foo"
/>
</Partial>
<p>
<a
@@ -12,16 +12,14 @@ export const config: RouteConfig = {
export default defineRoute((req, ctx) => {
return (
<Partial name="slot-1">
<Fader>
<p class="status-updated">updated</p>
<PropIsland
boolean={false}
number={42}
obj={{ foo: 123456 }}
strArr={["foo", "bar"]}
string="foobar"
/>
</Fader>
<p class="status-updated">updated</p>
<PropIsland
boolean={false}
number={42}
obj={{ foo: 123456 }}
strArr={["foo", "bar"]}
string="foobar"
/>
</Partial>
);
});