Skip to content

Commit d88b8f8

Browse files
fix(preset-typography): generate correct selector (#4931)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent f36c7db commit d88b8f8

File tree

5 files changed

+95
-54
lines changed

5 files changed

+95
-54
lines changed

packages-integrations/svelte-scoped/test/cases/prose/OutputDev.svelte

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,20 @@
235235
margin-bottom: 1.25em;
236236
padding-inline-start: 1.625em;
237237
}
238-
:where(ol > li::marker):not(
239-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
238+
:where(ol > li):not(
239+
:where(
240+
[class~="not-uno-prose"],
241+
:global([class~="not-uno-prose"] *)
242+
)::marker
240243
) {
241244
font-weight: 400;
242245
color: var(--un-prose-counters);
243246
}
244-
:where(ul > li::marker):not(
245-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
247+
:where(ul > li):not(
248+
:where(
249+
[class~="not-uno-prose"],
250+
:global([class~="not-uno-prose"] *)
251+
)::marker
246252
) {
247253
color: var(--un-prose-bullets);
248254
}
@@ -274,13 +280,19 @@
274280
margin-bottom: 1.6em;
275281
padding-inline-start: 1em;
276282
}
277-
:where(blockquote p:first-of-type::before):not(
278-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
283+
:where(blockquote p:first-of-type):not(
284+
:where(
285+
[class~="not-uno-prose"],
286+
:global([class~="not-uno-prose"] *)
287+
)::before
279288
) {
280289
content: open-quote;
281290
}
282-
:where(blockquote p:last-of-type::after):not(
283-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
291+
:where(blockquote p:last-of-type):not(
292+
:where(
293+
[class~="not-uno-prose"],
294+
:global([class~="not-uno-prose"] *)
295+
)::after
284296
) {
285297
content: close-quote;
286298
}
@@ -388,13 +400,19 @@
388400
font-weight: 600;
389401
font-size: 0.875em;
390402
}
391-
:where(code::before):not(
392-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
403+
:where(code):not(
404+
:where(
405+
[class~="not-uno-prose"],
406+
:global([class~="not-uno-prose"] *)
407+
)::before
393408
) {
394409
content: "`";
395410
}
396-
:where(code::after):not(
397-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
411+
:where(code):not(
412+
:where(
413+
[class~="not-uno-prose"],
414+
:global([class~="not-uno-prose"] *)
415+
)::after
398416
) {
399417
content: "`";
400418
}
@@ -465,13 +483,19 @@
465483
font-family: inherit;
466484
line-height: inherit;
467485
}
468-
:where(pre code::before):not(
469-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
486+
:where(pre code):not(
487+
:where(
488+
[class~="not-uno-prose"],
489+
:global([class~="not-uno-prose"] *)
490+
)::before
470491
) {
471492
content: none;
472493
}
473-
:where(pre code::after):not(
474-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
494+
:where(pre code):not(
495+
:where(
496+
[class~="not-uno-prose"],
497+
:global([class~="not-uno-prose"] *)
498+
)::after
475499
) {
476500
content: none;
477501
}

packages-integrations/svelte-scoped/test/cases/prose/OutputProd.svelte

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,20 @@
235235
margin-bottom: 1.25em;
236236
padding-inline-start: 1.625em;
237237
}
238-
:where(ol > li::marker):not(
239-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
238+
:where(ol > li):not(
239+
:where(
240+
[class~="not-uno-prose"],
241+
:global([class~="not-uno-prose"] *)
242+
)::marker
240243
) {
241244
font-weight: 400;
242245
color: var(--un-prose-counters);
243246
}
244-
:where(ul > li::marker):not(
245-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
247+
:where(ul > li):not(
248+
:where(
249+
[class~="not-uno-prose"],
250+
:global([class~="not-uno-prose"] *)
251+
)::marker
246252
) {
247253
color: var(--un-prose-bullets);
248254
}
@@ -274,13 +280,19 @@
274280
margin-bottom: 1.6em;
275281
padding-inline-start: 1em;
276282
}
277-
:where(blockquote p:first-of-type::before):not(
278-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
283+
:where(blockquote p:first-of-type):not(
284+
:where(
285+
[class~="not-uno-prose"],
286+
:global([class~="not-uno-prose"] *)
287+
)::before
279288
) {
280289
content: open-quote;
281290
}
282-
:where(blockquote p:last-of-type::after):not(
283-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
291+
:where(blockquote p:last-of-type):not(
292+
:where(
293+
[class~="not-uno-prose"],
294+
:global([class~="not-uno-prose"] *)
295+
)::after
284296
) {
285297
content: close-quote;
286298
}
@@ -388,13 +400,19 @@
388400
font-weight: 600;
389401
font-size: 0.875em;
390402
}
391-
:where(code::before):not(
392-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
403+
:where(code):not(
404+
:where(
405+
[class~="not-uno-prose"],
406+
:global([class~="not-uno-prose"] *)
407+
)::before
393408
) {
394409
content: "`";
395410
}
396-
:where(code::after):not(
397-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
411+
:where(code):not(
412+
:where(
413+
[class~="not-uno-prose"],
414+
:global([class~="not-uno-prose"] *)
415+
)::after
398416
) {
399417
content: "`";
400418
}
@@ -465,13 +483,19 @@
465483
font-family: inherit;
466484
line-height: inherit;
467485
}
468-
:where(pre code::before):not(
469-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
486+
:where(pre code):not(
487+
:where(
488+
[class~="not-uno-prose"],
489+
:global([class~="not-uno-prose"] *)
490+
)::before
470491
) {
471492
content: none;
472493
}
473-
:where(pre code::after):not(
474-
:where([class~="not-uno-prose"], :global([class~="not-uno-prose"] *))
494+
:where(pre code):not(
495+
:where(
496+
[class~="not-uno-prose"],
497+
:global([class~="not-uno-prose"] *)
498+
)::after
475499
) {
476500
content: none;
477501
}

packages-presets/preset-typography/src/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,7 @@ export const presetTypography = definePreset(<Theme extends TypographyTheme = Ty
129129

130130
return {
131131
[symbols.body]: css,
132-
[symbols.selector]: (selector) => {
133-
if (typeof options?.important === 'string') {
134-
selector = `${options.important} ${selector}`
135-
}
136-
if (!options?.compatibility?.noColonIs) {
137-
selector = `:is(${selector})`
138-
}
139-
return selector
140-
},
132+
[symbols.selector]: normalizeSelector,
141133
}
142134
},
143135
{ layer: 'typography', autocomplete: `${selectorName}-(${Object.keys(resolvedSizeScheme).join('|')})` },

packages-presets/preset-typography/src/resolve.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export function getCSS(preflights: TypographyCSSObject, options: TypographyOptio
3939
css += `${selectorOrKey}:${cssObjectOrValue}${important ? ' !important' : ''};`
4040
}
4141
else {
42-
const _selector = `:where(${selectorOrKey})${notProseSelector}`
42+
const [selectorOrGroup, pseudo] = selectorOrKey.split('::')
43+
const _selector = `:where(${selectorOrGroup})${notProseSelector}${pseudo ? `::${pseudo}` : ''}`
4344
css += `${_selector} {`
4445
for (const [key, value] of Object.entries(cssObjectOrValue)) {
4546
css += `${key}:${value}${important ? ' !important' : ''};`

test/__snapshots__/preset-typography.test.ts.snap

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)