fix: hydrate in twind-v1-plugin (#1050)

This commit is contained in:
y3km21
2023-03-13 01:31:41 +09:00
committed by GitHub
parent 7e72fa236c
commit 7f2ec612b2
15 changed files with 597 additions and 2 deletions
+14 -2
View File
@@ -1,5 +1,17 @@
import { getSheet, setup, TwindConfig } from "https://esm.sh/@twind/core@1.1.3";
import {
cssom,
getSheet,
setup,
TwindConfig,
} from "https://esm.sh/@twind/core@1.1.3";
import { STYLE_ELEMENT_ID } from "./shared.ts";
export default function hydrate(options: TwindConfig) {
setup(options, getSheet());
const elem = document.getElementById(STYLE_ELEMENT_ID) as HTMLStyleElement;
const sheet = cssom(elem);
sheet.resume = getSheet().resume.bind(sheet);
document.querySelector('[data-twind="claimed"]')?.remove();
setup(options, sheet);
}