@@ -132,35 +132,67 @@ function extractRule(rule: Rule, builder: StylesheetBuilder) {
132132 extractMedia ( rule . value , builder ) ;
133133 break ;
134134 }
135+ case "nested-declarations" : {
136+ const value = rule . value ;
137+
138+ const declarationBlock = value . declarations ;
139+ if ( declarationBlock ) {
140+ if ( declarationBlock . declarations ) {
141+ builder . newRuleFork ( ) ;
142+ for ( const declaration of declarationBlock . declarations ) {
143+ parseDeclaration ( declaration , builder ) ;
144+ }
145+ builder . applyRuleToSelectors ( ) ;
146+ }
147+
148+ if ( declarationBlock . importantDeclarations ) {
149+ builder . newRuleFork ( { important : true } ) ;
150+ for ( const declaration of declarationBlock . importantDeclarations ) {
151+ parseDeclaration ( declaration , builder ) ;
152+ }
153+ builder . applyRuleToSelectors ( ) ;
154+ }
155+ }
156+ break ;
157+ }
135158 case "style" : {
136- // If the rule is a style declaration, extract it with the `getExtractedStyle` function and store it in the `declarations` map
137- builder = builder . fork ( "style" ) ;
159+ const value = rule . value ;
138160
139- const declarationBlock = rule . value . declarations ;
140- const mapping = parsePropAtRule ( rule . value . rules ) ;
161+ const declarationBlock = value . declarations ;
162+ const mapping = parsePropAtRule ( value . rules ) ;
141163 const selectors = getSelectors (
142- rule . value . selectors ,
164+ value . selectors ,
143165 false ,
144166 builder . getOptions ( ) ,
145167 ) ;
146168
169+ // If the rule is a style declaration, extract it with the `getExtractedStyle` function and store it in the `declarations` map
170+ builder = builder . fork ( "style" , selectors ) ;
171+
147172 if ( declarationBlock ) {
148173 if ( declarationBlock . declarations ) {
149174 builder . newRule ( mapping ) ;
150175 for ( const declaration of declarationBlock . declarations ) {
151176 parseDeclaration ( declaration , builder ) ;
152177 }
153- builder . applyRuleToSelectors ( selectors ) ;
178+ builder . applyRuleToSelectors ( ) ;
154179 }
155180
156181 if ( declarationBlock . importantDeclarations ) {
157182 builder . newRule ( mapping , { important : true } ) ;
158183 for ( const declaration of declarationBlock . importantDeclarations ) {
159184 parseDeclaration ( declaration , builder ) ;
160185 }
161- builder . applyRuleToSelectors ( selectors ) ;
186+ builder . applyRuleToSelectors ( ) ;
162187 }
163188 }
189+
190+ if ( value . rules ) {
191+ for ( const nestedRule of value . rules ) {
192+ extractRule ( nestedRule , builder ) ;
193+ }
194+ }
195+
164196 break ;
165197 }
166198 case "layer-block" :
@@ -184,7 +216,6 @@ function extractRule(rule: Rule, builder: StylesheetBuilder) {
184216 case "counter-style" :
185217 case "moz-document" :
186218 case "nesting" :
187- case "nested-declarations" :
188219 case "viewport" :
189220 case "custom-media" :
190221 case "scope" :
0 commit comments