@@ -405,3 +405,91 @@ test('with @apply', () => {
405
405
` )
406
406
} )
407
407
} )
408
+
409
+ test ( 'keeps escaped underscores' , ( ) => {
410
+ let config = {
411
+ content : [
412
+ {
413
+ raw : '<div class="[&_.foo\\_\\_bar]:underline"></div>' ,
414
+ } ,
415
+ ] ,
416
+ corePlugins : { preflight : false } ,
417
+ }
418
+
419
+ let input = `
420
+ @tailwind base;
421
+ @tailwind components;
422
+ @tailwind utilities;
423
+ `
424
+
425
+ return run ( input , config ) . then ( ( result ) => {
426
+ expect ( result . css ) . toMatchFormattedCss ( css `
427
+ ${ defaults }
428
+
429
+ .\[\&_\.foo\\_\\_bar\]\:underline .foo__bar {
430
+ text-decoration-line : underline;
431
+ }
432
+ ` )
433
+ } )
434
+ } )
435
+
436
+ test ( 'keeps escaped underscores with multiple arbitrary variants' , ( ) => {
437
+ let config = {
438
+ content : [
439
+ {
440
+ raw : '<div class="[&_.foo\\_\\_bar]:[&_.bar\\_\\_baz]:underline"></div>' ,
441
+ } ,
442
+ ] ,
443
+ corePlugins : { preflight : false } ,
444
+ }
445
+
446
+ let input = `
447
+ @tailwind base;
448
+ @tailwind components;
449
+ @tailwind utilities;
450
+ `
451
+
452
+ return run ( input , config ) . then ( ( result ) => {
453
+ expect ( result . css ) . toMatchFormattedCss ( css `
454
+ ${ defaults }
455
+
456
+ .\[\&_\.foo\\_\\_bar\]\:\[\&_\.bar\\_\\_baz\]\:underline .bar__baz .foo__bar {
457
+ text-decoration-line : underline;
458
+ }
459
+ ` )
460
+ } )
461
+ } )
462
+
463
+ test ( 'keeps escaped underscores in arbitrary variants mixed with normal variants' , ( ) => {
464
+ let config = {
465
+ content : [
466
+ {
467
+ raw : `
468
+ <div class="[&_.foo\\_\\_bar]:hover:underline"></div>
469
+ <div class="hover:[&_.foo\\_\\_bar]:underline"></div>
470
+ ` ,
471
+ } ,
472
+ ] ,
473
+ corePlugins : { preflight : false } ,
474
+ }
475
+
476
+ let input = `
477
+ @tailwind base;
478
+ @tailwind components;
479
+ @tailwind utilities;
480
+ `
481
+
482
+ return run ( input , config ) . then ( ( result ) => {
483
+ expect ( result . css ) . toMatchFormattedCss ( css `
484
+ ${ defaults }
485
+
486
+ .\[\&_\.foo\\_\\_bar\]\:hover\:underline : hover .foo__bar {
487
+ text-decoration-line : underline;
488
+ }
489
+
490
+ .hover\:\[\&_\.foo\\_\\_bar\]\:underline .foo__bar : hover {
491
+ text-decoration-line : underline;
492
+ }
493
+ ` )
494
+ } )
495
+ } )
0 commit comments