File tree 2 files changed +114
-1
lines changed
2 files changed +114
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,10 @@ module.exports = function(input) {
53
53
} else if (
54
54
code === comma ||
55
55
code === colon ||
56
- ( code === slash && value . charCodeAt ( next + 1 ) !== star )
56
+ ( code === slash &&
57
+ value . charCodeAt ( next + 1 ) !== star &&
58
+ ( ! parent ||
59
+ ( parent && parent . type === "function" && parent . value !== "calc" ) ) )
57
60
) {
58
61
before = token ;
59
62
} else {
Original file line number Diff line number Diff line change @@ -492,6 +492,46 @@ var tests = [
492
492
}
493
493
]
494
494
} ,
495
+ {
496
+ message : "should correctly parse multiplication with spaces" ,
497
+ fixture : "calc(1 - 2)" ,
498
+ expected : [
499
+ {
500
+ type : "function" ,
501
+ sourceIndex : 0 ,
502
+ value : "calc" ,
503
+ before : "" ,
504
+ after : "" ,
505
+ nodes : [
506
+ {
507
+ type : "word" ,
508
+ sourceIndex : 5 ,
509
+ value : "1"
510
+ } ,
511
+ {
512
+ type : "space" ,
513
+ sourceIndex : 6 ,
514
+ value : " "
515
+ } ,
516
+ {
517
+ type : "word" ,
518
+ sourceIndex : 7 ,
519
+ value : "-"
520
+ } ,
521
+ {
522
+ type : "space" ,
523
+ sourceIndex : 8 ,
524
+ value : " "
525
+ } ,
526
+ {
527
+ type : "word" ,
528
+ sourceIndex : 9 ,
529
+ value : "2"
530
+ }
531
+ ]
532
+ }
533
+ ]
534
+ } ,
495
535
{
496
536
message : "should correctly parse multiplication with spaces" ,
497
537
fixture : "calc(1 * 2)" ,
@@ -532,6 +572,46 @@ var tests = [
532
572
}
533
573
]
534
574
} ,
575
+ {
576
+ message : "should correctly parse multiplication with spaces" ,
577
+ fixture : "calc(1 / 2)" ,
578
+ expected : [
579
+ {
580
+ type : "function" ,
581
+ sourceIndex : 0 ,
582
+ value : "calc" ,
583
+ before : "" ,
584
+ after : "" ,
585
+ nodes : [
586
+ {
587
+ type : "word" ,
588
+ sourceIndex : 5 ,
589
+ value : "1"
590
+ } ,
591
+ {
592
+ type : "space" ,
593
+ sourceIndex : 6 ,
594
+ value : " "
595
+ } ,
596
+ {
597
+ type : "word" ,
598
+ sourceIndex : 7 ,
599
+ value : "/"
600
+ } ,
601
+ {
602
+ type : "space" ,
603
+ sourceIndex : 8 ,
604
+ value : " "
605
+ } ,
606
+ {
607
+ type : "word" ,
608
+ sourceIndex : 9 ,
609
+ value : "2"
610
+ }
611
+ ]
612
+ }
613
+ ]
614
+ } ,
535
615
{
536
616
message : "should correctly parse multiplication without spaces" ,
537
617
fixture : "calc(1*2)" ,
@@ -562,6 +642,36 @@ var tests = [
562
642
}
563
643
]
564
644
} ,
645
+ {
646
+ message : "should correctly parse multiplication without spaces" ,
647
+ fixture : "calc(1/2)" ,
648
+ expected : [
649
+ {
650
+ type : "function" ,
651
+ sourceIndex : 0 ,
652
+ value : "calc" ,
653
+ before : "" ,
654
+ after : "" ,
655
+ nodes : [
656
+ {
657
+ type : "word" ,
658
+ sourceIndex : 5 ,
659
+ value : "1"
660
+ } ,
661
+ {
662
+ type : "word" ,
663
+ sourceIndex : 6 ,
664
+ value : "/"
665
+ } ,
666
+ {
667
+ type : "word" ,
668
+ sourceIndex : 7 ,
669
+ value : "2"
670
+ }
671
+ ]
672
+ }
673
+ ]
674
+ } ,
565
675
{
566
676
message : "should correctly process nested calc functions" ,
567
677
fixture : "calc(((768px - 100vw) / 2) - 15px)" ,
You can’t perform that action at this time.
0 commit comments