@@ -187,6 +187,63 @@ describe('Nested Selector Disambiguation', () => {
187187 const nestedContent = mainRule . block . children . head . data ;
188188 assert . strictEqual ( nestedContent . type , 'Rule' , 'Should parse as nested rule, not declaration' ) ;
189189 } ) ;
190+
191+ it ( 'should handle comma-separated selector list' , ( ) => {
192+ const css = `main {
193+ p:first-of-type, span {
194+ margin-top: 0;
195+ }
196+ }` ;
197+ const ast = parse ( css ) ;
198+
199+ const mainRule = ast . children . head . data ;
200+ assert . strictEqual ( mainRule . type , 'Rule' , 'Should parse main rule' ) ;
201+
202+ const nestedContent = mainRule . block . children . head . data ;
203+ assert . strictEqual ( nestedContent . type , 'Rule' , 'Should parse as nested rule, not declaration' ) ;
204+
205+ // Verify the selector list structure
206+ // The prelude IS the SelectorList
207+ const selectorList = nestedContent . prelude ;
208+ assert . strictEqual ( selectorList . type , 'SelectorList' , 'Should have SelectorList' ) ;
209+
210+ // Collect all selectors in the list
211+ const selectors = [ ] ;
212+ let current = selectorList . children . head ;
213+ while ( current ) {
214+ selectors . push ( current . data ) ;
215+ current = current . next ;
216+ }
217+
218+ assert . strictEqual ( selectors . length , 2 , 'Should have 2 selectors in the list' ) ;
219+
220+ // Verify first selector: p:first-of-type
221+ const firstSelectorChildren = [ ] ;
222+ current = selectors [ 0 ] . children . head ;
223+ while ( current ) {
224+ firstSelectorChildren . push ( current . data ) ;
225+ current = current . next ;
226+ }
227+ assert . strictEqual ( firstSelectorChildren [ 0 ] . type , 'TypeSelector' ) ;
228+ assert . strictEqual ( firstSelectorChildren [ 0 ] . name , 'p' ) ;
229+ assert . strictEqual ( firstSelectorChildren [ 1 ] . type , 'PseudoClassSelector' ) ;
230+ assert . strictEqual ( firstSelectorChildren [ 1 ] . name , 'first-of-type' ) ;
231+
232+ // Verify second selector: span
233+ const secondSelectorChildren = [ ] ;
234+ current = selectors [ 1 ] . children . head ;
235+ while ( current ) {
236+ secondSelectorChildren . push ( current . data ) ;
237+ current = current . next ;
238+ }
239+ assert . strictEqual ( secondSelectorChildren [ 0 ] . type , 'TypeSelector' ) ;
240+ assert . strictEqual ( secondSelectorChildren [ 0 ] . name , 'span' ) ;
241+
242+ // Verify the nested declaration
243+ const declaration = nestedContent . block . children . head . data ;
244+ assert . strictEqual ( declaration . type , 'Declaration' ) ;
245+ assert . strictEqual ( declaration . property , 'margin-top' ) ;
246+ } ) ;
190247 } ) ;
191248
192249 describe ( 'Regression tests for the original issue' , ( ) => {
0 commit comments