@@ -149,26 +149,33 @@ def preprocess_declarations(base_url, declarations, prelude=None):
149
149
# Nested rule.
150
150
if prelude is None :
151
151
continue
152
- declaration_prelude = declaration .prelude
153
- if NESTING_SELECTOR in declaration .prelude :
154
- # Replace & selector by parent.
155
- declaration_prelude = []
156
- for token in declaration .prelude :
157
- if token == NESTING_SELECTOR :
158
- declaration_prelude .extend (is_token )
159
- else :
160
- declaration_prelude .append (token )
161
- else :
162
- # No & selector, prepend parent.
163
- is_token = (
164
- LiteralToken (1 , 1 , ':' ),
165
- FunctionBlock (1 , 1 , 'is' , prelude ))
166
- declaration_prelude = [
167
- * is_token , WhitespaceToken (1 , 1 , ' ' ),
168
- * declaration .prelude ]
152
+ declaration_prelude = []
153
+ token_groups = [[]]
154
+ for token in declaration .prelude :
155
+ if token == ',' :
156
+ token_groups .append ([])
157
+ else :
158
+ token_groups [- 1 ].append (token )
159
+ for token_group in token_groups :
160
+ if NESTING_SELECTOR in token_group :
161
+ # Replace & selector by parent.
162
+ for token in declaration .prelude :
163
+ if token == NESTING_SELECTOR :
164
+ declaration_prelude .extend (is_token )
165
+ else :
166
+ declaration_prelude .append (token )
167
+ else :
168
+ # No & selector, prepend parent.
169
+ is_token = (
170
+ LiteralToken (1 , 1 , ':' ),
171
+ FunctionBlock (1 , 1 , 'is' , prelude ))
172
+ declaration_prelude .extend ([
173
+ * is_token , WhitespaceToken (1 , 1 , ' ' ),
174
+ * token_group ])
175
+ declaration_prelude .append (LiteralToken (1 , 1 , ',' ))
169
176
yield from preprocess_declarations (
170
177
base_url , parse_blocks_contents (declaration .content ),
171
- declaration_prelude )
178
+ declaration_prelude [: - 1 ] )
172
179
173
180
if declaration .type != 'declaration' :
174
181
continue
0 commit comments