File tree 2 files changed +70
-0
lines changed
2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -496,6 +496,14 @@ export const cssModules = {
496
496
String : [ 'highlight' ]
497
497
}
498
498
}
499
+ } ,
500
+ 'css-shadow-parts-1' : {
501
+ latest : true ,
502
+ pseudoElements : {
503
+ definitions : {
504
+ Selector : [ 'part' ]
505
+ }
506
+ }
499
507
}
500
508
} satisfies Record < string , SyntaxDefinition & { latest ?: true } > ;
501
509
Original file line number Diff line number Diff line change @@ -431,6 +431,68 @@ describe('CSS Modules', () => {
431
431
} ) ;
432
432
} ) ;
433
433
434
+ describe ( 'css-shadow-parts-1' , ( ) => {
435
+ it ( 'should parse ::part pseudo-element' , ( ) => {
436
+ const parse = createParser ( {
437
+ modules : [ 'css-shadow-parts-1' ]
438
+ } ) ;
439
+
440
+ expect ( parse ( '::part(button)' ) ) . toEqual (
441
+ ast . selector ( {
442
+ rules : [
443
+ ast . rule ( {
444
+ items : [
445
+ ast . pseudoElement ( {
446
+ name : 'part' ,
447
+ argument : ast . selector ( {
448
+ rules : [
449
+ ast . rule ( {
450
+ items : [ ast . tagName ( { name : 'button' } ) ]
451
+ } )
452
+ ]
453
+ } )
454
+ } )
455
+ ]
456
+ } )
457
+ ]
458
+ } )
459
+ ) ;
460
+
461
+ expect ( parse ( '::part(button-primary)' ) ) . toEqual (
462
+ ast . selector ( {
463
+ rules : [
464
+ ast . rule ( {
465
+ items : [
466
+ ast . pseudoElement ( {
467
+ name : 'part' ,
468
+ argument : ast . selector ( {
469
+ rules : [
470
+ ast . rule ( {
471
+ items : [ ast . tagName ( { name : 'button-primary' } ) ]
472
+ } )
473
+ ]
474
+ } )
475
+ } )
476
+ ]
477
+ } )
478
+ ]
479
+ } )
480
+ ) ;
481
+ } ) ;
482
+
483
+ it ( 'should reject ::part when module is not enabled' , ( ) => {
484
+ const parse = createParser ( {
485
+ syntax : {
486
+ pseudoElements : {
487
+ unknown : 'reject'
488
+ }
489
+ }
490
+ } ) ;
491
+
492
+ expect ( ( ) => parse ( '::part(button)' ) ) . toThrow ( 'Unknown pseudo-element "part".' ) ;
493
+ } ) ;
494
+ } ) ;
495
+
434
496
describe ( 'Multiple modules' , ( ) => {
435
497
it ( 'should support multiple modules at once' , ( ) => {
436
498
const parse = createParser ( {
You can’t perform that action at this time.
0 commit comments