autoprefixer 10.4.13 → 10.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +4 -4
  2. package/data/prefixes.js +187 -183
  3. package/lib/autoprefixer.js +16 -16
  4. package/lib/browsers.js +13 -13
  5. package/lib/declaration.js +92 -92
  6. package/lib/hacks/align-content.js +9 -9
  7. package/lib/hacks/align-items.js +7 -7
  8. package/lib/hacks/align-self.js +7 -7
  9. package/lib/hacks/block-logical.js +10 -10
  10. package/lib/hacks/border-radius.js +7 -7
  11. package/lib/hacks/break-props.js +16 -16
  12. package/lib/hacks/display-flex.js +9 -9
  13. package/lib/hacks/flex-direction.js +7 -7
  14. package/lib/hacks/flex.js +7 -7
  15. package/lib/hacks/gradient.js +259 -259
  16. package/lib/hacks/grid-column-align.js +6 -6
  17. package/lib/hacks/grid-row-align.js +6 -6
  18. package/lib/hacks/grid-rows-columns.js +23 -23
  19. package/lib/hacks/grid-template-areas.js +12 -12
  20. package/lib/hacks/grid-template.js +9 -9
  21. package/lib/hacks/grid-utils.js +26 -26
  22. package/lib/hacks/image-rendering.js +14 -14
  23. package/lib/hacks/inline-logical.js +6 -6
  24. package/lib/hacks/intrinsic.js +17 -17
  25. package/lib/hacks/justify-content.js +9 -9
  26. package/lib/hacks/mask-composite.js +2 -2
  27. package/lib/hacks/order.js +7 -7
  28. package/lib/hacks/overscroll-behavior.js +6 -6
  29. package/lib/hacks/pixelated.js +10 -10
  30. package/lib/hacks/print-color-adjust.js +7 -7
  31. package/lib/hacks/transform-decl.js +25 -25
  32. package/lib/hacks/user-select.js +10 -10
  33. package/lib/hacks/writing-mode.js +4 -4
  34. package/lib/info.js +6 -6
  35. package/lib/old-selector.js +16 -16
  36. package/lib/prefixer.js +20 -20
  37. package/lib/prefixes.js +124 -124
  38. package/lib/processor.js +159 -159
  39. package/lib/resolution.js +17 -17
  40. package/lib/selector.js +67 -67
  41. package/lib/supports.js +167 -167
  42. package/lib/transition.js +118 -118
  43. package/lib/value.js +26 -26
  44. package/package.json +7 -3
package/lib/processor.js CHANGED
@@ -396,141 +396,6 @@ class Processor {
396
396
  })
397
397
  }
398
398
 
399
- /**
400
- * Remove unnecessary pefixes
401
- */
402
- remove(css, result) {
403
- // At-rules
404
- let resolution = this.prefixes.remove['@resolution']
405
-
406
- css.walkAtRules((rule, i) => {
407
- if (this.prefixes.remove[`@${rule.name}`]) {
408
- if (!this.disabled(rule, result)) {
409
- rule.parent.removeChild(i)
410
- }
411
- } else if (
412
- rule.name === 'media' &&
413
- rule.params.includes('-resolution') &&
414
- resolution
415
- ) {
416
- resolution.clean(rule)
417
- }
418
- })
419
-
420
- // Selectors
421
- for (let checker of this.prefixes.remove.selectors) {
422
- css.walkRules((rule, i) => {
423
- if (checker.check(rule)) {
424
- if (!this.disabled(rule, result)) {
425
- rule.parent.removeChild(i)
426
- }
427
- }
428
- })
429
- }
430
-
431
- return css.walkDecls((decl, i) => {
432
- if (this.disabled(decl, result)) return
433
-
434
- let rule = decl.parent
435
- let unprefixed = this.prefixes.unprefixed(decl.prop)
436
-
437
- // Transition
438
- if (decl.prop === 'transition' || decl.prop === 'transition-property') {
439
- this.prefixes.transition.remove(decl)
440
- }
441
-
442
- // Properties
443
- if (
444
- this.prefixes.remove[decl.prop] &&
445
- this.prefixes.remove[decl.prop].remove
446
- ) {
447
- let notHack = this.prefixes.group(decl).down(other => {
448
- return this.prefixes.normalize(other.prop) === unprefixed
449
- })
450
-
451
- if (unprefixed === 'flex-flow') {
452
- notHack = true
453
- }
454
-
455
- if (decl.prop === '-webkit-box-orient') {
456
- let hacks = { 'flex-direction': true, 'flex-flow': true }
457
- if (!decl.parent.some(j => hacks[j.prop])) return
458
- }
459
-
460
- if (notHack && !this.withHackValue(decl)) {
461
- if (decl.raw('before').includes('\n')) {
462
- this.reduceSpaces(decl)
463
- }
464
- rule.removeChild(i)
465
- return
466
- }
467
- }
468
-
469
- // Values
470
- for (let checker of this.prefixes.values('remove', unprefixed)) {
471
- if (!checker.check) continue
472
- if (!checker.check(decl.value)) continue
473
-
474
- unprefixed = checker.unprefixed
475
- let notHack = this.prefixes.group(decl).down(other => {
476
- return other.value.includes(unprefixed)
477
- })
478
-
479
- if (notHack) {
480
- rule.removeChild(i)
481
- return
482
- }
483
- }
484
- })
485
- }
486
-
487
- /**
488
- * Some rare old values, which is not in standard
489
- */
490
- withHackValue(decl) {
491
- return decl.prop === '-webkit-background-clip' && decl.value === 'text'
492
- }
493
-
494
- /**
495
- * Check for grid/flexbox options.
496
- */
497
- disabledValue(node, result) {
498
- if (this.gridStatus(node, result) === false && node.type === 'decl') {
499
- if (node.prop === 'display' && node.value.includes('grid')) {
500
- return true
501
- }
502
- }
503
- if (this.prefixes.options.flexbox === false && node.type === 'decl') {
504
- if (node.prop === 'display' && node.value.includes('flex')) {
505
- return true
506
- }
507
- }
508
- if (node.type === 'decl' && node.prop === 'content') {
509
- return true
510
- }
511
-
512
- return this.disabled(node, result)
513
- }
514
-
515
- /**
516
- * Check for grid/flexbox options.
517
- */
518
- disabledDecl(node, result) {
519
- if (this.gridStatus(node, result) === false && node.type === 'decl') {
520
- if (node.prop.includes('grid') || node.prop === 'justify-items') {
521
- return true
522
- }
523
- }
524
- if (this.prefixes.options.flexbox === false && node.type === 'decl') {
525
- let other = ['order', 'justify-content', 'align-items', 'align-content']
526
- if (node.prop.includes('flex') || other.includes(node.prop)) {
527
- return true
528
- }
529
- }
530
-
531
- return this.disabled(node, result)
532
- }
533
-
534
399
  /**
535
400
  * Check for control comment and global options
536
401
  */
@@ -590,35 +455,43 @@ class Processor {
590
455
  }
591
456
 
592
457
  /**
593
- * Normalize spaces in cascade declaration group
458
+ * Check for grid/flexbox options.
594
459
  */
595
- reduceSpaces(decl) {
596
- let stop = false
597
- this.prefixes.group(decl).up(() => {
598
- stop = true
599
- return true
600
- })
601
- if (stop) {
602
- return
460
+ disabledDecl(node, result) {
461
+ if (this.gridStatus(node, result) === false && node.type === 'decl') {
462
+ if (node.prop.includes('grid') || node.prop === 'justify-items') {
463
+ return true
464
+ }
465
+ }
466
+ if (this.prefixes.options.flexbox === false && node.type === 'decl') {
467
+ let other = ['order', 'justify-content', 'align-items', 'align-content']
468
+ if (node.prop.includes('flex') || other.includes(node.prop)) {
469
+ return true
470
+ }
603
471
  }
604
472
 
605
- let parts = decl.raw('before').split('\n')
606
- let prevMin = parts[parts.length - 1].length
607
- let diff = false
608
-
609
- this.prefixes.group(decl).down(other => {
610
- parts = other.raw('before').split('\n')
611
- let last = parts.length - 1
612
-
613
- if (parts[last].length > prevMin) {
614
- if (diff === false) {
615
- diff = parts[last].length - prevMin
616
- }
473
+ return this.disabled(node, result)
474
+ }
617
475
 
618
- parts[last] = parts[last].slice(0, -diff)
619
- other.raws.before = parts.join('\n')
476
+ /**
477
+ * Check for grid/flexbox options.
478
+ */
479
+ disabledValue(node, result) {
480
+ if (this.gridStatus(node, result) === false && node.type === 'decl') {
481
+ if (node.prop === 'display' && node.value.includes('grid')) {
482
+ return true
620
483
  }
621
- })
484
+ }
485
+ if (this.prefixes.options.flexbox === false && node.type === 'decl') {
486
+ if (node.prop === 'display' && node.value.includes('flex')) {
487
+ return true
488
+ }
489
+ }
490
+ if (node.type === 'decl' && node.prop === 'content') {
491
+ return true
492
+ }
493
+
494
+ return this.disabled(node, result)
622
495
  }
623
496
 
624
497
  /**
@@ -713,6 +586,133 @@ class Processor {
713
586
  node._autoprefixerGridStatus = value
714
587
  return value
715
588
  }
589
+
590
+ /**
591
+ * Normalize spaces in cascade declaration group
592
+ */
593
+ reduceSpaces(decl) {
594
+ let stop = false
595
+ this.prefixes.group(decl).up(() => {
596
+ stop = true
597
+ return true
598
+ })
599
+ if (stop) {
600
+ return
601
+ }
602
+
603
+ let parts = decl.raw('before').split('\n')
604
+ let prevMin = parts[parts.length - 1].length
605
+ let diff = false
606
+
607
+ this.prefixes.group(decl).down(other => {
608
+ parts = other.raw('before').split('\n')
609
+ let last = parts.length - 1
610
+
611
+ if (parts[last].length > prevMin) {
612
+ if (diff === false) {
613
+ diff = parts[last].length - prevMin
614
+ }
615
+
616
+ parts[last] = parts[last].slice(0, -diff)
617
+ other.raws.before = parts.join('\n')
618
+ }
619
+ })
620
+ }
621
+
622
+ /**
623
+ * Remove unnecessary pefixes
624
+ */
625
+ remove(css, result) {
626
+ // At-rules
627
+ let resolution = this.prefixes.remove['@resolution']
628
+
629
+ css.walkAtRules((rule, i) => {
630
+ if (this.prefixes.remove[`@${rule.name}`]) {
631
+ if (!this.disabled(rule, result)) {
632
+ rule.parent.removeChild(i)
633
+ }
634
+ } else if (
635
+ rule.name === 'media' &&
636
+ rule.params.includes('-resolution') &&
637
+ resolution
638
+ ) {
639
+ resolution.clean(rule)
640
+ }
641
+ })
642
+
643
+ // Selectors
644
+ for (let checker of this.prefixes.remove.selectors) {
645
+ css.walkRules((rule, i) => {
646
+ if (checker.check(rule)) {
647
+ if (!this.disabled(rule, result)) {
648
+ rule.parent.removeChild(i)
649
+ }
650
+ }
651
+ })
652
+ }
653
+
654
+ return css.walkDecls((decl, i) => {
655
+ if (this.disabled(decl, result)) return
656
+
657
+ let rule = decl.parent
658
+ let unprefixed = this.prefixes.unprefixed(decl.prop)
659
+
660
+ // Transition
661
+ if (decl.prop === 'transition' || decl.prop === 'transition-property') {
662
+ this.prefixes.transition.remove(decl)
663
+ }
664
+
665
+ // Properties
666
+ if (
667
+ this.prefixes.remove[decl.prop] &&
668
+ this.prefixes.remove[decl.prop].remove
669
+ ) {
670
+ let notHack = this.prefixes.group(decl).down(other => {
671
+ return this.prefixes.normalize(other.prop) === unprefixed
672
+ })
673
+
674
+ if (unprefixed === 'flex-flow') {
675
+ notHack = true
676
+ }
677
+
678
+ if (decl.prop === '-webkit-box-orient') {
679
+ let hacks = { 'flex-direction': true, 'flex-flow': true }
680
+ if (!decl.parent.some(j => hacks[j.prop])) return
681
+ }
682
+
683
+ if (notHack && !this.withHackValue(decl)) {
684
+ if (decl.raw('before').includes('\n')) {
685
+ this.reduceSpaces(decl)
686
+ }
687
+ rule.removeChild(i)
688
+ return
689
+ }
690
+ }
691
+
692
+ // Values
693
+ for (let checker of this.prefixes.values('remove', unprefixed)) {
694
+ if (!checker.check) continue
695
+ if (!checker.check(decl.value)) continue
696
+
697
+ unprefixed = checker.unprefixed
698
+ let notHack = this.prefixes.group(decl).down(other => {
699
+ return other.value.includes(unprefixed)
700
+ })
701
+
702
+ if (notHack) {
703
+ rule.removeChild(i)
704
+ return
705
+ }
706
+ }
707
+ })
708
+ }
709
+
710
+ /**
711
+ * Some rare old values, which is not in standard
712
+ */
713
+ withHackValue(decl) {
714
+ return decl.prop === '-webkit-background-clip' && decl.value === 'text'
715
+ }
716
716
  }
717
717
 
718
718
  module.exports = Processor
package/lib/resolution.js CHANGED
@@ -7,6 +7,23 @@ const REGEXP = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpcm|dpi|x)/gi
7
7
  const SPLIT = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpcm|dpi|x)/i
8
8
 
9
9
  class Resolution extends Prefixer {
10
+ /**
11
+ * Remove prefixed queries
12
+ */
13
+ clean(rule) {
14
+ if (!this.bad) {
15
+ this.bad = []
16
+ for (let prefix of this.prefixes) {
17
+ this.bad.push(this.prefixName(prefix, 'min'))
18
+ this.bad.push(this.prefixName(prefix, 'max'))
19
+ }
20
+ }
21
+
22
+ rule.params = utils.editList(rule.params, queries => {
23
+ return queries.filter(query => this.bad.every(i => !query.includes(i)))
24
+ })
25
+ }
26
+
10
27
  /**
11
28
  * Return prefixed query name
12
29
  */
@@ -39,23 +56,6 @@ class Resolution extends Prefixer {
39
56
  return this.prefixName(prefix, name) + colon + value
40
57
  }
41
58
 
42
- /**
43
- * Remove prefixed queries
44
- */
45
- clean(rule) {
46
- if (!this.bad) {
47
- this.bad = []
48
- for (let prefix of this.prefixes) {
49
- this.bad.push(this.prefixName(prefix, 'min'))
50
- this.bad.push(this.prefixName(prefix, 'max'))
51
- }
52
- }
53
-
54
- rule.params = utils.editList(rule.params, queries => {
55
- return queries.filter(query => this.bad.every(i => !query.includes(i)))
56
- })
57
- }
58
-
59
59
  /**
60
60
  * Add prefixed queries
61
61
  */
package/lib/selector.js CHANGED
@@ -12,36 +12,70 @@ class Selector extends Prefixer {
12
12
  }
13
13
 
14
14
  /**
15
- * Is rule selectors need to be prefixed
15
+ * Clone and add prefixes for at-rule
16
16
  */
17
- check(rule) {
18
- if (rule.selector.includes(this.name)) {
19
- return !!rule.selector.match(this.regexp())
17
+ add(rule, prefix) {
18
+ let prefixeds = this.prefixeds(rule)
19
+
20
+ if (this.already(rule, prefixeds, prefix)) {
21
+ return
20
22
  }
21
23
 
22
- return false
24
+ let cloned = this.clone(rule, { selector: prefixeds[this.name][prefix] })
25
+ rule.parent.insertBefore(rule, cloned)
23
26
  }
24
27
 
25
28
  /**
26
- * Return prefixed version of selector
29
+ * Is rule already prefixed before
27
30
  */
28
- prefixed(prefix) {
29
- return this.name.replace(/^(\W*)/, `$1${prefix}`)
31
+ already(rule, prefixeds, prefix) {
32
+ let index = rule.parent.index(rule) - 1
33
+
34
+ while (index >= 0) {
35
+ let before = rule.parent.nodes[index]
36
+
37
+ if (before.type !== 'rule') {
38
+ return false
39
+ }
40
+
41
+ let some = false
42
+ for (let key in prefixeds[this.name]) {
43
+ let prefixed = prefixeds[this.name][key]
44
+ if (before.selector === prefixed) {
45
+ if (prefix === key) {
46
+ return true
47
+ } else {
48
+ some = true
49
+ break
50
+ }
51
+ }
52
+ }
53
+ if (!some) {
54
+ return false
55
+ }
56
+
57
+ index -= 1
58
+ }
59
+
60
+ return false
30
61
  }
31
62
 
32
63
  /**
33
- * Lazy loadRegExp for name
64
+ * Is rule selectors need to be prefixed
34
65
  */
35
- regexp(prefix) {
36
- if (!this.regexpCache.has(prefix)) {
37
- let name = prefix ? this.prefixed(prefix) : this.name
38
- this.regexpCache.set(
39
- prefix,
40
- new RegExp(`(^|[^:"'=])${utils.escapeRegexp(name)}`, 'gi')
41
- )
66
+ check(rule) {
67
+ if (rule.selector.includes(this.name)) {
68
+ return !!rule.selector.match(this.regexp())
42
69
  }
43
70
 
44
- return this.regexpCache.get(prefix)
71
+ return false
72
+ }
73
+
74
+ /**
75
+ * Return function to fast find prefixed selector
76
+ */
77
+ old(prefix) {
78
+ return new OldSelector(this, prefix)
45
79
  }
46
80
 
47
81
  /**
@@ -51,6 +85,13 @@ class Selector extends Prefixer {
51
85
  return Browsers.prefixes()
52
86
  }
53
87
 
88
+ /**
89
+ * Return prefixed version of selector
90
+ */
91
+ prefixed(prefix) {
92
+ return this.name.replace(/^(\W*)/, `$1${prefix}`)
93
+ }
94
+
54
95
  /**
55
96
  * Return all possible selector prefixes
56
97
  */
@@ -84,38 +125,18 @@ class Selector extends Prefixer {
84
125
  }
85
126
 
86
127
  /**
87
- * Is rule already prefixed before
128
+ * Lazy loadRegExp for name
88
129
  */
89
- already(rule, prefixeds, prefix) {
90
- let index = rule.parent.index(rule) - 1
91
-
92
- while (index >= 0) {
93
- let before = rule.parent.nodes[index]
94
-
95
- if (before.type !== 'rule') {
96
- return false
97
- }
98
-
99
- let some = false
100
- for (let key in prefixeds[this.name]) {
101
- let prefixed = prefixeds[this.name][key]
102
- if (before.selector === prefixed) {
103
- if (prefix === key) {
104
- return true
105
- } else {
106
- some = true
107
- break
108
- }
109
- }
110
- }
111
- if (!some) {
112
- return false
113
- }
114
-
115
- index -= 1
130
+ regexp(prefix) {
131
+ if (!this.regexpCache.has(prefix)) {
132
+ let name = prefix ? this.prefixed(prefix) : this.name
133
+ this.regexpCache.set(
134
+ prefix,
135
+ new RegExp(`(^|[^:"'=])${utils.escapeRegexp(name)}`, 'gi')
136
+ )
116
137
  }
117
138
 
118
- return false
139
+ return this.regexpCache.get(prefix)
119
140
  }
120
141
 
121
142
  /**
@@ -124,27 +145,6 @@ class Selector extends Prefixer {
124
145
  replace(selector, prefix) {
125
146
  return selector.replace(this.regexp(), `$1${this.prefixed(prefix)}`)
126
147
  }
127
-
128
- /**
129
- * Clone and add prefixes for at-rule
130
- */
131
- add(rule, prefix) {
132
- let prefixeds = this.prefixeds(rule)
133
-
134
- if (this.already(rule, prefixeds, prefix)) {
135
- return
136
- }
137
-
138
- let cloned = this.clone(rule, { selector: prefixeds[this.name][prefix] })
139
- rule.parent.insertBefore(rule, cloned)
140
- }
141
-
142
- /**
143
- * Return function to fast find prefixed selector
144
- */
145
- old(prefix) {
146
- return new OldSelector(this, prefix)
147
- }
148
148
  }
149
149
 
150
150
  module.exports = Selector