fix: twind styles not updated on partial nav (#2017)
This commit is contained in:
+17
-21
@@ -17,32 +17,28 @@ export default function(state) { hydrate(options, state); }`;
|
||||
entrypoints: { "main": main },
|
||||
async renderAsync(ctx) {
|
||||
sheet.reset(undefined);
|
||||
const res = await ctx.renderAsync();
|
||||
await ctx.renderAsync();
|
||||
const cssTexts = [...sheet.target];
|
||||
const snapshot = sheet.reset();
|
||||
const scripts = [];
|
||||
let cssText: string;
|
||||
if (res.requiresHydration) {
|
||||
const precedences = snapshot[1] as number[];
|
||||
cssText = cssTexts.map((cssText, i) =>
|
||||
`${cssText}/*${precedences[i].toString(36)}*/`
|
||||
).join("\n");
|
||||
const mappings: (string | [string, string])[] = [];
|
||||
for (
|
||||
const [key, value] of (snapshot[3] as Map<string, string>).entries()
|
||||
) {
|
||||
if (key === value) {
|
||||
mappings.push(key);
|
||||
} else {
|
||||
mappings.push([key, value]);
|
||||
}
|
||||
const precedences = snapshot[1] as number[];
|
||||
|
||||
const cssText = cssTexts.map((cssText, i) =>
|
||||
`${cssText}/*${precedences[i].toString(36)}*/`
|
||||
).join("\n");
|
||||
|
||||
const mappings: (string | [string, string])[] = [];
|
||||
for (
|
||||
const [key, value] of (snapshot[3] as Map<string, string>).entries()
|
||||
) {
|
||||
if (key === value) {
|
||||
mappings.push(key);
|
||||
} else {
|
||||
mappings.push([key, value]);
|
||||
}
|
||||
scripts.push({ entrypoint: "main", state: mappings });
|
||||
} else {
|
||||
cssText = cssTexts.join("\n");
|
||||
}
|
||||
|
||||
return {
|
||||
scripts,
|
||||
scripts: [{ entrypoint: "main", state: mappings }],
|
||||
styles: [{ cssText, id: STYLE_ELEMENT_ID }],
|
||||
};
|
||||
},
|
||||
|
||||
+2
-6
@@ -24,14 +24,10 @@ export default function(state) { hydrate(options, state); }`;
|
||||
name: "twind",
|
||||
entrypoints: { "main": main },
|
||||
async renderAsync(ctx) {
|
||||
const res = await ctx.renderAsync();
|
||||
await ctx.renderAsync();
|
||||
const cssText = stringify(sheet.target);
|
||||
const scripts = [];
|
||||
if (res.requiresHydration) {
|
||||
scripts.push({ entrypoint: "main", state: [] });
|
||||
}
|
||||
return {
|
||||
scripts,
|
||||
scripts: [{ entrypoint: "main", state: [] }],
|
||||
styles: [{ cssText, id: STYLE_ELEMENT_ID }],
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user