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
@@ -1,5 +1,5 @@
1
1
  let browserslist = require('browserslist')
2
- let { agents } = require('caniuse-lite')
2
+ let { agents } = require('caniuse-lite/dist/unpacker/agents')
3
3
  let pico = require('picocolors')
4
4
 
5
5
  let Browsers = require('./browsers')
@@ -96,9 +96,9 @@ function plugin(...reqs) {
96
96
  }
97
97
 
98
98
  let brwlstOpts = {
99
+ env: options.env,
99
100
  ignoreUnknownVersions: options.ignoreUnknownVersions,
100
- stats: options.stats,
101
- env: options.env
101
+ stats: options.stats
102
102
  }
103
103
 
104
104
  function loadPrefixes(opts) {
@@ -114,12 +114,21 @@ function plugin(...reqs) {
114
114
  }
115
115
 
116
116
  return {
117
- postcssPlugin: 'autoprefixer',
117
+ browsers: reqs,
118
+
119
+ info(opts) {
120
+ opts = opts || {}
121
+ opts.from = opts.from || process.cwd()
122
+ return getInfo(loadPrefixes(opts))
123
+ },
118
124
 
125
+ options,
126
+
127
+ postcssPlugin: 'autoprefixer',
119
128
  prepare(result) {
120
129
  let prefixes = loadPrefixes({
121
- from: result.opts.from,
122
- env: options.env
130
+ env: options.env,
131
+ from: result.opts.from
123
132
  })
124
133
 
125
134
  return {
@@ -133,16 +142,7 @@ function plugin(...reqs) {
133
142
  }
134
143
  }
135
144
  }
136
- },
137
-
138
- info(opts) {
139
- opts = opts || {}
140
- opts.from = opts.from || process.cwd()
141
- return getInfo(loadPrefixes(opts))
142
- },
143
-
144
- options,
145
- browsers: reqs
145
+ }
146
146
  }
147
147
  }
148
148
 
package/lib/browsers.js CHANGED
@@ -1,9 +1,16 @@
1
1
  let browserslist = require('browserslist')
2
- let agents = require('caniuse-lite').agents
2
+ let { agents } = require('caniuse-lite/dist/unpacker/agents')
3
3
 
4
4
  let utils = require('./utils')
5
5
 
6
6
  class Browsers {
7
+ constructor(data, requirements, options, browserslistOpts) {
8
+ this.data = data
9
+ this.options = options || {}
10
+ this.browserslistOpts = browserslistOpts || {}
11
+ this.selected = this.parse(requirements)
12
+ }
13
+
7
14
  /**
8
15
  * Return all prefixes for default browser data
9
16
  */
@@ -35,11 +42,11 @@ class Browsers {
35
42
  return this.prefixesRegexp.test(value)
36
43
  }
37
44
 
38
- constructor(data, requirements, options, browserslistOpts) {
39
- this.data = data
40
- this.options = options || {}
41
- this.browserslistOpts = browserslistOpts || {}
42
- this.selected = this.parse(requirements)
45
+ /**
46
+ * Is browser is selected by requirements
47
+ */
48
+ isSelected(browser) {
49
+ return this.selected.includes(browser)
43
50
  }
44
51
 
45
52
  /**
@@ -67,13 +74,6 @@ class Browsers {
67
74
  }
68
75
  return `-${prefix}-`
69
76
  }
70
-
71
- /**
72
- * Is browser is selected by requirements
73
- */
74
- isSelected(browser) {
75
- return this.selected.includes(browser)
76
- }
77
77
  }
78
78
 
79
79
  module.exports = Browsers
@@ -4,58 +4,70 @@ let utils = require('./utils')
4
4
 
5
5
  class Declaration extends Prefixer {
6
6
  /**
7
- * Always true, because we already get prefixer by property name
7
+ * Clone and add prefixes for declaration
8
8
  */
9
- check(/* decl */) {
10
- return true
9
+ add(decl, prefix, prefixes, result) {
10
+ let prefixed = this.prefixed(decl.prop, prefix)
11
+ if (
12
+ this.isAlready(decl, prefixed) ||
13
+ this.otherPrefixes(decl.value, prefix)
14
+ ) {
15
+ return undefined
16
+ }
17
+ return this.insert(decl, prefix, prefixes, result)
11
18
  }
12
19
 
13
20
  /**
14
- * Return prefixed version of property
21
+ * Calculate indentation to create visual cascade
15
22
  */
16
- prefixed(prop, prefix) {
17
- return prefix + prop
23
+ calcBefore(prefixes, decl, prefix = '') {
24
+ let max = this.maxPrefixed(prefixes, decl)
25
+ let diff = max - utils.removeNote(prefix).length
26
+
27
+ let before = decl.raw('before')
28
+ if (diff > 0) {
29
+ before += Array(diff).fill(' ').join('')
30
+ }
31
+
32
+ return before
18
33
  }
19
34
 
20
35
  /**
21
- * Return unprefixed version of property
36
+ * Always true, because we already get prefixer by property name
22
37
  */
23
- normalize(prop) {
24
- return prop
38
+ check(/* decl */) {
39
+ return true
25
40
  }
26
41
 
27
42
  /**
28
- * Check `value`, that it contain other prefixes, rather than `prefix`
43
+ * Clone and insert new declaration
29
44
  */
30
- otherPrefixes(value, prefix) {
31
- for (let other of Browsers.prefixes()) {
32
- if (other === prefix) {
33
- continue
34
- }
35
- if (value.includes(other)) {
36
- return value.replace(/var\([^)]+\)/, '').includes(other)
37
- }
45
+ insert(decl, prefix, prefixes) {
46
+ let cloned = this.set(this.clone(decl), prefix)
47
+ if (!cloned) return undefined
48
+
49
+ let already = decl.parent.some(
50
+ i => i.prop === cloned.prop && i.value === cloned.value
51
+ )
52
+ if (already) {
53
+ return undefined
38
54
  }
39
- return false
40
- }
41
55
 
42
- /**
43
- * Set prefix to declaration
44
- */
45
- set(decl, prefix) {
46
- decl.prop = this.prefixed(decl.prop, prefix)
47
- return decl
56
+ if (this.needCascade(decl)) {
57
+ cloned.raws.before = this.calcBefore(prefixes, decl, prefix)
58
+ }
59
+ return decl.parent.insertBefore(decl, cloned)
48
60
  }
49
61
 
50
62
  /**
51
- * Should we use visual cascade for prefixes
63
+ * Did this declaration has this prefix above
52
64
  */
53
- needCascade(decl) {
54
- if (!decl._autoprefixerCascade) {
55
- decl._autoprefixerCascade =
56
- this.all.options.cascade !== false && decl.raw('before').includes('\n')
65
+ isAlready(decl, prefixed) {
66
+ let already = this.all.group(decl).up(i => i.prop === prefixed)
67
+ if (!already) {
68
+ already = this.all.group(decl).down(i => i.prop === prefixed)
57
69
  }
58
- return decl._autoprefixerCascade
70
+ return already
59
71
  }
60
72
 
61
73
  /**
@@ -79,82 +91,50 @@ class Declaration extends Prefixer {
79
91
  }
80
92
 
81
93
  /**
82
- * Calculate indentation to create visual cascade
94
+ * Should we use visual cascade for prefixes
83
95
  */
84
- calcBefore(prefixes, decl, prefix = '') {
85
- let max = this.maxPrefixed(prefixes, decl)
86
- let diff = max - utils.removeNote(prefix).length
87
-
88
- let before = decl.raw('before')
89
- if (diff > 0) {
90
- before += Array(diff).fill(' ').join('')
96
+ needCascade(decl) {
97
+ if (!decl._autoprefixerCascade) {
98
+ decl._autoprefixerCascade =
99
+ this.all.options.cascade !== false && decl.raw('before').includes('\n')
91
100
  }
92
-
93
- return before
101
+ return decl._autoprefixerCascade
94
102
  }
95
103
 
96
104
  /**
97
- * Remove visual cascade
105
+ * Return unprefixed version of property
98
106
  */
99
- restoreBefore(decl) {
100
- let lines = decl.raw('before').split('\n')
101
- let min = lines[lines.length - 1]
102
-
103
- this.all.group(decl).up(prefixed => {
104
- let array = prefixed.raw('before').split('\n')
105
- let last = array[array.length - 1]
106
- if (last.length < min.length) {
107
- min = last
108
- }
109
- })
110
-
111
- lines[lines.length - 1] = min
112
- decl.raws.before = lines.join('\n')
107
+ normalize(prop) {
108
+ return prop
113
109
  }
114
110
 
115
111
  /**
116
- * Clone and insert new declaration
112
+ * Return list of prefixed properties to clean old prefixes
117
113
  */
118
- insert(decl, prefix, prefixes) {
119
- let cloned = this.set(this.clone(decl), prefix)
120
- if (!cloned) return undefined
121
-
122
- let already = decl.parent.some(
123
- i => i.prop === cloned.prop && i.value === cloned.value
124
- )
125
- if (already) {
126
- return undefined
127
- }
128
-
129
- if (this.needCascade(decl)) {
130
- cloned.raws.before = this.calcBefore(prefixes, decl, prefix)
131
- }
132
- return decl.parent.insertBefore(decl, cloned)
114
+ old(prop, prefix) {
115
+ return [this.prefixed(prop, prefix)]
133
116
  }
134
117
 
135
118
  /**
136
- * Did this declaration has this prefix above
119
+ * Check `value`, that it contain other prefixes, rather than `prefix`
137
120
  */
138
- isAlready(decl, prefixed) {
139
- let already = this.all.group(decl).up(i => i.prop === prefixed)
140
- if (!already) {
141
- already = this.all.group(decl).down(i => i.prop === prefixed)
121
+ otherPrefixes(value, prefix) {
122
+ for (let other of Browsers.prefixes()) {
123
+ if (other === prefix) {
124
+ continue
125
+ }
126
+ if (value.includes(other)) {
127
+ return value.replace(/var\([^)]+\)/, '').includes(other)
128
+ }
142
129
  }
143
- return already
130
+ return false
144
131
  }
145
132
 
146
133
  /**
147
- * Clone and add prefixes for declaration
134
+ * Return prefixed version of property
148
135
  */
149
- add(decl, prefix, prefixes, result) {
150
- let prefixed = this.prefixed(decl.prop, prefix)
151
- if (
152
- this.isAlready(decl, prefixed) ||
153
- this.otherPrefixes(decl.value, prefix)
154
- ) {
155
- return undefined
156
- }
157
- return this.insert(decl, prefix, prefixes, result)
136
+ prefixed(prop, prefix) {
137
+ return prefix + prop
158
138
  }
159
139
 
160
140
  /**
@@ -177,10 +157,30 @@ class Declaration extends Prefixer {
177
157
  }
178
158
 
179
159
  /**
180
- * Return list of prefixed properties to clean old prefixes
160
+ * Remove visual cascade
181
161
  */
182
- old(prop, prefix) {
183
- return [this.prefixed(prop, prefix)]
162
+ restoreBefore(decl) {
163
+ let lines = decl.raw('before').split('\n')
164
+ let min = lines[lines.length - 1]
165
+
166
+ this.all.group(decl).up(prefixed => {
167
+ let array = prefixed.raw('before').split('\n')
168
+ let last = array[array.length - 1]
169
+ if (last.length < min.length) {
170
+ min = last
171
+ }
172
+ })
173
+
174
+ lines[lines.length - 1] = min
175
+ decl.raws.before = lines.join('\n')
176
+ }
177
+
178
+ /**
179
+ * Set prefix to declaration
180
+ */
181
+ set(decl, prefix) {
182
+ decl.prop = this.prefixed(decl.prop, prefix)
183
+ return decl
184
184
  }
185
185
  }
186
186
 
@@ -2,6 +2,13 @@ let flexSpec = require('./flex-spec')
2
2
  let Declaration = require('../declaration')
3
3
 
4
4
  class AlignContent extends Declaration {
5
+ /**
6
+ * Return property name by final spec
7
+ */
8
+ normalize() {
9
+ return 'align-content'
10
+ }
11
+
5
12
  /**
6
13
  * Change property name for 2012 spec
7
14
  */
@@ -14,13 +21,6 @@ class AlignContent extends Declaration {
14
21
  return super.prefixed(prop, prefix)
15
22
  }
16
23
 
17
- /**
18
- * Return property name by final spec
19
- */
20
- normalize() {
21
- return 'align-content'
22
- }
23
-
24
24
  /**
25
25
  * Change value for 2012 spec and ignore prefix for 2009
26
26
  */
@@ -42,8 +42,8 @@ AlignContent.names = ['align-content', 'flex-line-pack']
42
42
  AlignContent.oldValues = {
43
43
  'flex-end': 'end',
44
44
  'flex-start': 'start',
45
- 'space-between': 'justify',
46
- 'space-around': 'distribute'
45
+ 'space-around': 'distribute',
46
+ 'space-between': 'justify'
47
47
  }
48
48
 
49
49
  module.exports = AlignContent
@@ -2,6 +2,13 @@ let flexSpec = require('./flex-spec')
2
2
  let Declaration = require('../declaration')
3
3
 
4
4
  class AlignItems extends Declaration {
5
+ /**
6
+ * Return property name by final spec
7
+ */
8
+ normalize() {
9
+ return 'align-items'
10
+ }
11
+
5
12
  /**
6
13
  * Change property name for 2009 and 2012 specs
7
14
  */
@@ -17,13 +24,6 @@ class AlignItems extends Declaration {
17
24
  return super.prefixed(prop, prefix)
18
25
  }
19
26
 
20
- /**
21
- * Return property name by final spec
22
- */
23
- normalize() {
24
- return 'align-items'
25
- }
26
-
27
27
  /**
28
28
  * Change value for 2009 and 2012 specs
29
29
  */
@@ -11,6 +11,13 @@ class AlignSelf extends Declaration {
11
11
  )
12
12
  }
13
13
 
14
+ /**
15
+ * Return property name by final spec
16
+ */
17
+ normalize() {
18
+ return 'align-self'
19
+ }
20
+
14
21
  /**
15
22
  * Change property name for 2012 specs
16
23
  */
@@ -23,13 +30,6 @@ class AlignSelf extends Declaration {
23
30
  return super.prefixed(prop, prefix)
24
31
  }
25
32
 
26
- /**
27
- * Return property name by final spec
28
- */
29
- normalize() {
30
- return 'align-self'
31
- }
32
-
33
33
  /**
34
34
  * Change value for 2012 spec and ignore prefix for 2009
35
35
  */
@@ -1,16 +1,6 @@
1
1
  let Declaration = require('../declaration')
2
2
 
3
3
  class BlockLogical extends Declaration {
4
- /**
5
- * Use old syntax for -moz- and -webkit-
6
- */
7
- prefixed(prop, prefix) {
8
- if (prop.includes('-start')) {
9
- return prefix + prop.replace('-block-start', '-before')
10
- }
11
- return prefix + prop.replace('-block-end', '-after')
12
- }
13
-
14
4
  /**
15
5
  * Return property name by spec
16
6
  */
@@ -20,6 +10,16 @@ class BlockLogical extends Declaration {
20
10
  }
21
11
  return prop.replace('-after', '-block-end')
22
12
  }
13
+
14
+ /**
15
+ * Use old syntax for -moz- and -webkit-
16
+ */
17
+ prefixed(prop, prefix) {
18
+ if (prop.includes('-start')) {
19
+ return prefix + prop.replace('-block-start', '-before')
20
+ }
21
+ return prefix + prop.replace('-block-end', '-after')
22
+ }
23
23
  }
24
24
 
25
25
  BlockLogical.names = [
@@ -1,6 +1,13 @@
1
1
  let Declaration = require('../declaration')
2
2
 
3
3
  class BorderRadius extends Declaration {
4
+ /**
5
+ * Return unprefixed version of property
6
+ */
7
+ normalize(prop) {
8
+ return BorderRadius.toNormal[prop] || prop
9
+ }
10
+
4
11
  /**
5
12
  * Change syntax, when add Mozilla prefix
6
13
  */
@@ -10,13 +17,6 @@ class BorderRadius extends Declaration {
10
17
  }
11
18
  return super.prefixed(prop, prefix)
12
19
  }
13
-
14
- /**
15
- * Return unprefixed version of property
16
- */
17
- normalize(prop) {
18
- return BorderRadius.toNormal[prop] || prop
19
- }
20
20
  }
21
21
 
22
22
  BorderRadius.names = ['border-radius']
@@ -2,10 +2,16 @@ let Declaration = require('../declaration')
2
2
 
3
3
  class BreakProps extends Declaration {
4
4
  /**
5
- * Change name for -webkit- and -moz- prefix
5
+ * Don’t prefix some values
6
6
  */
7
- prefixed(prop, prefix) {
8
- return `${prefix}column-${prop}`
7
+ insert(decl, prefix, prefixes) {
8
+ if (decl.prop !== 'break-inside') {
9
+ return super.insert(decl, prefix, prefixes)
10
+ }
11
+ if (/region/i.test(decl.value) || /page/i.test(decl.value)) {
12
+ return undefined
13
+ }
14
+ return super.insert(decl, prefix, prefixes)
9
15
  }
10
16
 
11
17
  /**
@@ -21,6 +27,13 @@ class BreakProps extends Declaration {
21
27
  return 'break-after'
22
28
  }
23
29
 
30
+ /**
31
+ * Change name for -webkit- and -moz- prefix
32
+ */
33
+ prefixed(prop, prefix) {
34
+ return `${prefix}column-${prop}`
35
+ }
36
+
24
37
  /**
25
38
  * Change prefixed value for avoid-column and avoid-page
26
39
  */
@@ -33,19 +46,6 @@ class BreakProps extends Declaration {
33
46
  }
34
47
  return super.set(decl, prefix)
35
48
  }
36
-
37
- /**
38
- * Don’t prefix some values
39
- */
40
- insert(decl, prefix, prefixes) {
41
- if (decl.prop !== 'break-inside') {
42
- return super.insert(decl, prefix, prefixes)
43
- }
44
- if (/region/i.test(decl.value) || /page/i.test(decl.value)) {
45
- return undefined
46
- }
47
- return super.insert(decl, prefix, prefixes)
48
- }
49
49
  }
50
50
 
51
51
  BreakProps.names = [
@@ -17,6 +17,15 @@ class DisplayFlex extends Value {
17
17
  return decl.prop === 'display' && decl.value === this.name
18
18
  }
19
19
 
20
+ /**
21
+ * Change value for old specs
22
+ */
23
+ old(prefix) {
24
+ let prefixed = this.prefixed(prefix)
25
+ if (!prefixed) return undefined
26
+ return new OldValue(this.name, prefixed)
27
+ }
28
+
20
29
  /**
21
30
  * Return value by spec
22
31
  */
@@ -49,15 +58,6 @@ class DisplayFlex extends Value {
49
58
  replace(string, prefix) {
50
59
  return this.prefixed(prefix)
51
60
  }
52
-
53
- /**
54
- * Change value for old specs
55
- */
56
- old(prefix) {
57
- let prefixed = this.prefixed(prefix)
58
- if (!prefixed) return undefined
59
- return new OldValue(this.name, prefixed)
60
- }
61
61
  }
62
62
 
63
63
  DisplayFlex.names = ['display-flex', 'inline-flex']
@@ -2,13 +2,6 @@ let flexSpec = require('./flex-spec')
2
2
  let Declaration = require('../declaration')
3
3
 
4
4
  class FlexDirection extends Declaration {
5
- /**
6
- * Return property name by final spec
7
- */
8
- normalize() {
9
- return 'flex-direction'
10
- }
11
-
12
5
  /**
13
6
  * Use two properties for 2009 spec
14
7
  */
@@ -53,6 +46,13 @@ class FlexDirection extends Declaration {
53
46
  return decl.parent.insertBefore(decl, cloned)
54
47
  }
55
48
 
49
+ /**
50
+ * Return property name by final spec
51
+ */
52
+ normalize() {
53
+ return 'flex-direction'
54
+ }
55
+
56
56
  /**
57
57
  * Clean two properties for 2009 spec
58
58
  */
package/lib/hacks/flex.js CHANGED
@@ -4,6 +4,13 @@ let flexSpec = require('./flex-spec')
4
4
  let Declaration = require('../declaration')
5
5
 
6
6
  class Flex extends Declaration {
7
+ /**
8
+ * Return property name by final spec
9
+ */
10
+ normalize() {
11
+ return 'flex'
12
+ }
13
+
7
14
  /**
8
15
  * Change property name for 2009 spec
9
16
  */
@@ -16,13 +23,6 @@ class Flex extends Declaration {
16
23
  return super.prefixed(prop, prefix)
17
24
  }
18
25
 
19
- /**
20
- * Return property name by final spec
21
- */
22
- normalize() {
23
- return 'flex'
24
- }
25
-
26
26
  /**
27
27
  * Spec 2009 supports only first argument
28
28
  * Spec 2012 disallows unitless basis