@@ -312,23 +312,28 @@ const tests = [
312
312
// input: ':import("~/lol.css") { foo: __foo; }',
313
313
// expected: ':import("~/lol.css") { foo: __foo; }'
314
314
// },
315
- {
316
- should : 'compile in pure mode' ,
317
- input : ':global(.foo).bar, [type="radio"] ~ .label, :not(.foo), #bar {}' ,
318
- options : { mode : 'pure' } ,
319
- expected :
320
- '.foo:local(.bar), [type="radio"] ~ :local(.label), :not(:local(.foo)), :local(#bar) {}' ,
321
- } ,
322
315
// {
323
- // should: 'compile explict global element',
324
- // input: ':global(input) {}',
325
- // expected: 'input {}'
316
+ // should: 'incorrectly handle nested selectors',
317
+ // input: '.bar:not(:global .foo, .baz) {}',
318
+ // expected: ':local(.bar):not(.foo, .baz) {}',
319
+ // },
320
+ // {
321
+ // should: 'compile in pure mode',
322
+ // input: ':global(.foo).bar, [type="radio"] ~ .label, :not(.foo), #bar {}',
323
+ // options: { mode: 'pure' },
324
+ // expected:
325
+ // '.foo:local(.bar), [type="radio"] ~ :local(.label), :not(:local(.foo)), :local(#bar) {}',
326
326
// },
327
327
// {
328
- // should: 'compile explict global attribute ',
329
- // input: ':global([type="radio"]), :not(:global [type="radio"] ) {}',
330
- // expected: '[type="radio"], :not([type="radio"]) {}'
328
+ // should: 'compile explict global element ',
329
+ // input: ':global(input ) {}',
330
+ // expected: 'input {}',
331
331
// },
332
+ {
333
+ should : 'compile explict global attribute' ,
334
+ input : ':global([type="radio"]), :not(:global [type="radio"]) {}' ,
335
+ expected : '[type="radio"], :not([type="radio"]) {}' ,
336
+ } ,
332
337
// {
333
338
// should: 'throw on invalid mode',
334
339
// input: '',
@@ -343,83 +348,83 @@ const tests = [
343
348
// {
344
349
// should: 'throw on nested :locals',
345
350
// input: ':local(:local(.foo)) {}',
346
- // error: /is not allowed inside/
351
+ // error: /is not allowed inside/,
347
352
// },
348
353
// {
349
354
// should: 'throw on nested :globals',
350
355
// input: ':global(:global(.foo)) {}',
351
- // error: /is not allowed inside/
356
+ // error: /is not allowed inside/,
352
357
// },
353
358
// {
354
359
// should: 'throw on nested mixed',
355
360
// input: ':local(:global(.foo)) {}',
356
- // error: /is not allowed inside/
361
+ // error: /is not allowed inside/,
357
362
// },
358
363
// {
359
364
// should: 'throw on nested broad :local',
360
365
// input: ':global(:local .foo) {}',
361
- // error: /is not allowed inside/
366
+ // error: /is not allowed inside/,
362
367
// },
363
368
// {
364
369
// should: 'throw on incorrect spacing with broad :global',
365
370
// input: '.foo :global.bar {}',
366
- // error: /Missing whitespace after :global/
371
+ // error: /Missing whitespace after :global/,
367
372
// },
368
373
// {
369
374
// should: 'throw on incorrect spacing with broad :local',
370
375
// input: '.foo:local .bar {}',
371
- // error: /Missing whitespace before :local/
376
+ // error: /Missing whitespace before :local/,
372
377
// },
373
378
// {
374
379
// should: 'throw on not pure selector (global class)',
375
380
// input: ':global(.foo) {}',
376
381
// options: { mode: 'pure' },
377
- // error: /":global\(\.foo\)" is not pure/
382
+ // error: /":global\(\.foo\)" is not pure/,
378
383
// },
379
384
// {
380
385
// should: 'throw on not pure selector (with multiple 1)',
381
386
// input: '.foo, :global(.bar) {}',
382
387
// options: { mode: 'pure' },
383
- // error: /".foo, :global\(\.bar\)" is not pure/
388
+ // error: /".foo, :global\(\.bar\)" is not pure/,
384
389
// },
385
390
// {
386
391
// should: 'throw on not pure selector (with multiple 2)',
387
392
// input: ':global(.bar), .foo {}',
388
393
// options: { mode: 'pure' },
389
- // error: /":global\(\.bar\), .foo" is not pure/
394
+ // error: /":global\(\.bar\), .foo" is not pure/,
390
395
// },
391
396
// {
392
397
// should: 'throw on not pure selector (element)',
393
398
// input: 'input {}',
394
399
// options: { mode: 'pure' },
395
- // error: /"input" is not pure/
400
+ // error: /"input" is not pure/,
396
401
// },
397
402
// {
398
403
// should: 'throw on not pure selector (attribute)',
399
404
// input: '[type="radio"] {}',
400
405
// options: { mode: 'pure' },
401
- // error: /"\[type="radio"\]" is not pure/
406
+ // error: /"\[type="radio"\]" is not pure/,
402
407
// },
403
408
// {
404
409
// should: 'throw on not pure keyframes',
405
410
// input: '@keyframes :global(foo) {}',
406
411
// options: { mode: 'pure' },
407
- // error: /@keyframes :global\(\.\.\.\) is not allowed in pure mode/
412
+ // error: /@keyframes :global\(\.\.\.\) is not allowed in pure mode/,
408
413
// },
409
414
// {
410
415
// should: 'pass through global element',
411
416
// input: 'input {}',
412
- // expected: 'input {}'
417
+ // expected: 'input {}',
413
418
// },
414
419
// {
415
420
// should: 'localise class and pass through element',
416
421
// input: '.foo input {}',
417
- // expected: ':local(.foo) input {}'
422
+ // expected: ':local(.foo) input {}',
418
423
// },
419
424
// {
420
425
// should: 'pass through attribute selector',
421
426
// input: '[type="radio"] {}',
422
- // expected: '[type="radio"] {}'
427
+ // expected: '[type="radio"] {}',
423
428
// },
424
429
// {
425
430
// should: 'not modify urls without option',
@@ -430,15 +435,15 @@ const tests = [
430
435
// expected:
431
436
// ':local(.a) { background: url(./image.png); }\n' +
432
437
// '.b { background: url(image.png); }\n' +
433
- // ':local(.c) { background: url("./image.png"); }'
438
+ // ':local(.c) { background: url("./image.png"); }',
434
439
// },
435
440
// {
436
441
// should: 'rewrite url in local block',
437
442
// input:
438
443
// '.a { background: url(./image.png); }\n' +
439
444
// ':global .b { background: url(image.png); }\n' +
440
445
// '.c { background: url("./image.png"); }\n' +
441
- // ' .c { background: url(\ './image.png\ '); }\n' +
446
+ // " .c { background: url('./image.png'); }\n" +
442
447
// '.d { background: -webkit-image-set(url("./image.png") 1x, url("./image2x.png") 2x); }\n' +
443
448
// '@font-face { src: url("./font.woff"); }\n' +
444
449
// '@-webkit-font-face { src: url("./font.woff"); }\n' +
@@ -450,7 +455,7 @@ const tests = [
450
455
// rewriteUrl: function(global, url) {
451
456
// const mode = global ? 'global' : 'local';
452
457
// return '(' + mode + ')' + url + '"' + mode + '"';
453
- // }
458
+ // },
454
459
// },
455
460
// expected:
456
461
// ':local(.a) { background: url((local\\)./image.png\\"local\\"); }\n' +
@@ -468,7 +473,7 @@ const tests = [
468
473
// {
469
474
// should: 'not crash on atrule without nodes',
470
475
// input: '@charset "utf-8";',
471
- // expected: '@charset "utf-8";'
476
+ // expected: '@charset "utf-8";',
472
477
// },
473
478
// {
474
479
// should: 'not crash on a rule without nodes',
@@ -480,32 +485,32 @@ const tests = [
480
485
// return root;
481
486
// })(),
482
487
// // postcss-less's stringify would honor `ruleWithoutBody` and omit the trailing `{}`
483
- // expected: ':local(.a) {\n :local(.b) {}\n}'
488
+ // expected: ':local(.a) {\n :local(.b) {}\n}',
484
489
// },
485
490
// {
486
491
// should: 'not break unicode characters',
487
492
// input: '.a { content: "\\2193" }',
488
- // expected: ':local(.a) { content: "\\2193" }'
493
+ // expected: ':local(.a) { content: "\\2193" }',
489
494
// },
490
495
// {
491
496
// should: 'not break unicode characters',
492
497
// input: '.a { content: "\\2193\\2193" }',
493
- // expected: ':local(.a) { content: "\\2193\\2193" }'
498
+ // expected: ':local(.a) { content: "\\2193\\2193" }',
494
499
// },
495
500
// {
496
501
// should: 'not break unicode characters',
497
502
// input: '.a { content: "\\2193 \\2193" }',
498
- // expected: ':local(.a) { content: "\\2193 \\2193" }'
503
+ // expected: ':local(.a) { content: "\\2193 \\2193" }',
499
504
// },
500
505
// {
501
506
// should: 'not break unicode characters',
502
507
// input: '.a { content: "\\2193\\2193\\2193" }',
503
- // expected: ':local(.a) { content: "\\2193\\2193\\2193" }'
508
+ // expected: ':local(.a) { content: "\\2193\\2193\\2193" }',
504
509
// },
505
510
// {
506
511
// should: 'not break unicode characters',
507
512
// input: '.a { content: "\\2193 \\2193 \\2193" }',
508
- // expected: ':local(.a) { content: "\\2193 \\2193 \\2193" }'
513
+ // expected: ':local(.a) { content: "\\2193 \\2193 \\2193" }',
509
514
// },
510
515
] ;
511
516
0 commit comments