@@ -188,6 +188,7 @@ class Stylesheet {
188
188
this . transformMedia ( root , root . rule [ '@media' ] ) ;
189
189
this . transformSupports ( root , root . rule [ '@supports' ] ) ;
190
190
this . transformContainer ( root , root . rule [ '@container' ] ) ;
191
+ this . transformStartingStyle ( root , root . rule [ '@starting-style' ] ) ;
191
192
192
193
this . transformSimplePseudos ( root , root . rule ) ;
193
194
this . transformSelectors ( root , root . rule ) ;
@@ -408,6 +409,11 @@ class Stylesheet {
408
409
selectorRule [ '@container' ] ,
409
410
conditions ,
410
411
) ;
412
+ this . transformStartingStyle (
413
+ root ,
414
+ selectorRule ! [ '@starting-style' ] ,
415
+ conditions ,
416
+ ) ;
411
417
} ) ;
412
418
}
413
419
@@ -445,6 +451,11 @@ class Stylesheet {
445
451
this . transformLayer ( root , mediaRule ! [ '@layer' ] , conditions ) ;
446
452
this . transformSupports ( root , mediaRule ! [ '@supports' ] , conditions ) ;
447
453
this . transformContainer ( root , mediaRule ! [ '@container' ] , conditions ) ;
454
+ this . transformStartingStyle (
455
+ root ,
456
+ mediaRule ! [ '@starting-style' ] ,
457
+ conditions ,
458
+ ) ;
448
459
}
449
460
}
450
461
}
@@ -481,6 +492,11 @@ class Stylesheet {
481
492
this . transformLayer ( root , containerRule ! [ '@layer' ] , conditions ) ;
482
493
this . transformSupports ( root , containerRule ! [ '@supports' ] , conditions ) ;
483
494
this . transformMedia ( root , containerRule ! [ '@media' ] , conditions ) ;
495
+ this . transformStartingStyle (
496
+ root ,
497
+ containerRule ! [ '@starting-style' ] ,
498
+ conditions ,
499
+ ) ;
484
500
} ) ;
485
501
}
486
502
}
@@ -516,6 +532,11 @@ class Stylesheet {
516
532
this . transformMedia ( root , layerRule ! [ '@media' ] , conditions ) ;
517
533
this . transformSupports ( root , layerRule ! [ '@supports' ] , conditions ) ;
518
534
this . transformContainer ( root , layerRule ! [ '@container' ] , conditions ) ;
535
+ this . transformStartingStyle (
536
+ root ,
537
+ layerRule ! [ '@starting-style' ] ,
538
+ conditions ,
539
+ ) ;
519
540
} ) ;
520
541
}
521
542
}
@@ -550,6 +571,11 @@ class Stylesheet {
550
571
this . transformLayer ( root , supportsRule ! [ '@layer' ] , conditions ) ;
551
572
this . transformMedia ( root , supportsRule ! [ '@media' ] , conditions ) ;
552
573
this . transformContainer ( root , supportsRule ! [ '@container' ] , conditions ) ;
574
+ this . transformStartingStyle (
575
+ root ,
576
+ supportsRule ! [ '@starting-style' ] ,
577
+ conditions ,
578
+ ) ;
553
579
} ) ;
554
580
}
555
581
}
@@ -589,6 +615,42 @@ class Stylesheet {
589
615
}
590
616
}
591
617
618
+ transformStartingStyle (
619
+ root : CSSStyleBlock | CSSSelectorBlock ,
620
+ rules : WithQueries < StyleWithSelectors > [ '@starting-style' ] ,
621
+ parentConditions : Array < string > = [ ] ,
622
+ ) {
623
+ if ( rules ) {
624
+ // Check if there are any nested at-rule keys inside this block.
625
+ // The presence of any key starting with '@' indicates nested queries,
626
+ // which are not allowed for @starting -style.
627
+ const nestedAtRuleKey = Object . keys ( rules ) . find ( ( key ) =>
628
+ key . startsWith ( '@' ) ,
629
+ ) ;
630
+ if ( nestedAtRuleKey ) {
631
+ throw new Error (
632
+ `Nested at-rules (e.g. "${ nestedAtRuleKey } ") are not allowed inside @starting-style.` ,
633
+ ) ;
634
+ }
635
+
636
+ const conditions = [ ...parentConditions , '@starting-style' ] ;
637
+
638
+ this . addConditionalRule (
639
+ {
640
+ selector : root . selector ,
641
+ rule : omit ( rules , specialKeys ) ,
642
+ } ,
643
+ conditions ,
644
+ ) ;
645
+
646
+ // Process any simple pseudos or selectors associated with this style.
647
+ if ( root . type === 'local' ) {
648
+ this . transformSimplePseudos ( root , rules , conditions ) ;
649
+ this . transformSelectors ( root , rules , conditions ) ;
650
+ }
651
+ }
652
+ }
653
+
592
654
toCss ( ) {
593
655
const css : Array < string > = [ ] ;
594
656
0 commit comments