@@ -325,7 +325,7 @@ export function optimizeAst(
325
325
326
326
// Create fallback values for usages of the `color-mix(…)` function that reference variables
327
327
// found in the theme config.
328
- if ( node . value . includes ( 'color-mix(' ) ) {
328
+ if ( polyfills & Polyfills . ColorMix && node . value . includes ( 'color-mix(' ) ) {
329
329
let ast = ValueParser . parse ( node . value )
330
330
331
331
let didGenerateFallback = false
@@ -348,10 +348,11 @@ export function optimizeAst(
348
348
// `oklab(…)` functions again as their support in Safari <16 is very limited.
349
349
let colorspace = node . nodes [ 2 ]
350
350
if (
351
- ( colorspace . kind === 'word' && colorspace . value === 'oklab' ) ||
352
- colorspace . value === 'oklch' ||
353
- colorspace . value === 'lab' ||
354
- colorspace . value === 'lch'
351
+ colorspace . kind === 'word' &&
352
+ ( colorspace . value === 'oklab' ||
353
+ colorspace . value === 'oklch' ||
354
+ colorspace . value === 'lab' ||
355
+ colorspace . value === 'lch' )
355
356
) {
356
357
colorspace . value = 'srgb'
357
358
}
@@ -404,9 +405,8 @@ export function optimizeAst(
404
405
return
405
406
}
406
407
407
- // Collect fallbacks for `@property` rules for Firefox support
408
- // We turn these into rules on `:root` or `*` and some pseudo-elements
409
- // based on the value of `inherits``
408
+ // Collect fallbacks for `@property` rules for Firefox support We turn these into rules on
409
+ // `:root` or `*` and some pseudo-elements based on the value of `inherits`
410
410
if ( polyfills & Polyfills . AtProperty ) {
411
411
let property = node . params
412
412
let initialValue = null
@@ -448,8 +448,7 @@ export function optimizeAst(
448
448
transform ( child , copy . nodes , context , depth + 1 )
449
449
}
450
450
451
- // Only track `@keyframes` that could be removed, when they were defined
452
- // inside of a `@theme`.
451
+ // Only track `@keyframes` that could be removed, when they were defined inside of a `@theme`.
453
452
if ( node . name === '@keyframes' && context . theme ) {
454
453
keyframes . add ( copy )
455
454
}
@@ -572,32 +571,30 @@ export function optimizeAst(
572
571
573
572
// Fallbacks
574
573
if ( polyfills & Polyfills . AtProperty ) {
575
- {
576
- let fallbackAst = [ ]
574
+ let fallbackAst = [ ]
577
575
578
- if ( propertyFallbacksRoot . length > 0 ) {
579
- fallbackAst . push ( rule ( ':root, :host' , propertyFallbacksRoot ) )
580
- }
576
+ if ( propertyFallbacksRoot . length > 0 ) {
577
+ fallbackAst . push ( rule ( ':root, :host' , propertyFallbacksRoot ) )
578
+ }
581
579
582
- if ( propertyFallbacksUniversal . length > 0 ) {
583
- fallbackAst . push ( rule ( '*, ::before, ::after, ::backdrop' , propertyFallbacksUniversal ) )
584
- }
580
+ if ( propertyFallbacksUniversal . length > 0 ) {
581
+ fallbackAst . push ( rule ( '*, ::before, ::after, ::backdrop' , propertyFallbacksUniversal ) )
582
+ }
585
583
586
- if ( fallbackAst . length > 0 ) {
587
- let firstNonCommentIndex = newAst . findIndex ( ( item ) => item . kind !== 'comment' )
588
- if ( firstNonCommentIndex === - 1 ) firstNonCommentIndex = 0
589
- newAst . splice (
590
- firstNonCommentIndex ,
591
- 0 ,
592
- atRule (
593
- '@supports' ,
594
- // We can't write a supports query for `@property` directly so we have to test for
595
- // features that are added around the same time in Mozilla and Safari.
596
- '((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b))))' ,
597
- [ rule ( '@layer base' , fallbackAst ) ] ,
598
- ) ,
599
- )
600
- }
584
+ if ( fallbackAst . length > 0 ) {
585
+ let firstNonCommentIndex = newAst . findIndex ( ( item ) => item . kind !== 'comment' )
586
+ if ( firstNonCommentIndex === - 1 ) firstNonCommentIndex = 0
587
+ newAst . splice (
588
+ firstNonCommentIndex ,
589
+ 0 ,
590
+ atRule (
591
+ '@supports' ,
592
+ // We can't write a supports query for `@property` directly so we have to test for
593
+ // features that are added around the same time in Mozilla and Safari.
594
+ '((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b))))' ,
595
+ [ rule ( '@layer base' , fallbackAst ) ] ,
596
+ ) ,
597
+ )
601
598
}
602
599
}
603
600
0 commit comments