Skip to content

Commit 35c743c

Browse files
fix(desktop): fail annotation CSS generation if defaults stay conditional
1 parent cb2f3da commit 35c743c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎apps/desktop/scripts/build-preview-annotation-css.mjs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ const compilerInput = [
2929
annotationSource.replace('@import "tailwindcss";', "@tailwind utilities;"),
3030
].join("\n");
3131
const compiler = await compile(compilerInput, { base: appRoot });
32-
// Tailwind registers its `--tw-*` defaults with `@property`, which browsers
33-
// ignore inside a shadow tree, and only emits the `*` fallback for engines
34-
// that lack `@property`. The overlay lives in a shadow root, so lift that
35-
// fallback out of its `@supports` guard: without it `border`, `shadow-*`
36-
// and `ring-*` silently render nothing.
37-
const css = compiler
38-
.build([...candidates])
39-
.replace(/(@layer properties \{\n) @supports [^\n]*\{\n([\s\S]*?)\n \}\n(\})/, "$1$2\n$3");
40-
if (/@layer properties \{\s*@supports/.test(css)) {
32+
// Shadow-root styles cannot register @property defaults. Make Tailwind's
33+
// fallback unconditional so border, shadow, and ring utilities have defaults.
34+
const compiledCss = compiler.build([...candidates]);
35+
const css = compiledCss.replace(
36+
/(@layer properties \{\n) @supports [^\n]*\{\n([\s\S]*?)\n \}\n(\})/,
37+
"$1$2\n$3",
38+
);
39+
if (css === compiledCss || /@layer properties\s*\{\s*@supports\b/.test(css)) {
4140
throw new Error("Tailwind @property fallback was not unwrapped; update the pattern above.");
4241
}
4342
const encodedCss = `'${css

0 commit comments

Comments
 (0)