autoprefixer 10.4.11 → 10.4.12
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.
- package/lib/hacks/gradient.js +32 -13
- package/package.json +3 -3
package/lib/hacks/gradient.js
CHANGED
|
@@ -14,9 +14,10 @@ class Gradient extends Value {
|
|
|
14
14
|
replace(string, prefix) {
|
|
15
15
|
let ast = parser(string)
|
|
16
16
|
for (let node of ast.nodes) {
|
|
17
|
-
|
|
17
|
+
let gradientName = this.name // gradient name
|
|
18
|
+
if (node.type === 'function' && node.value === gradientName) {
|
|
18
19
|
node.nodes = this.newDirection(node.nodes)
|
|
19
|
-
node.nodes = this.normalize(node.nodes)
|
|
20
|
+
node.nodes = this.normalize(node.nodes, gradientName)
|
|
20
21
|
if (prefix === '-webkit- old') {
|
|
21
22
|
let changes = this.oldWebkit(node)
|
|
22
23
|
if (!changes) {
|
|
@@ -56,7 +57,7 @@ class Gradient extends Value {
|
|
|
56
57
|
/**
|
|
57
58
|
* Normalize angle
|
|
58
59
|
*/
|
|
59
|
-
normalize(nodes) {
|
|
60
|
+
normalize(nodes, gradientName) {
|
|
60
61
|
if (!nodes[0]) return nodes
|
|
61
62
|
|
|
62
63
|
if (/-?\d+(.\d+)?grad/.test(nodes[0].value)) {
|
|
@@ -71,14 +72,23 @@ class Gradient extends Value {
|
|
|
71
72
|
nodes[0].value = `${num}deg`
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
if (
|
|
76
|
+
gradientName === 'linear-gradient' ||
|
|
77
|
+
gradientName === 'repeating-linear-gradient'
|
|
78
|
+
) {
|
|
79
|
+
let direction = nodes[0].value
|
|
80
|
+
|
|
81
|
+
// Unitless zero for `<angle>` values are allowed in CSS gradients and transforms.
|
|
82
|
+
// Spec: https://github.com/w3c/csswg-drafts/commit/602789171429b2231223ab1e5acf8f7f11652eb3
|
|
83
|
+
if (direction === '0deg' || direction === '0') {
|
|
84
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'top')
|
|
85
|
+
} else if (direction === '90deg') {
|
|
86
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'right')
|
|
87
|
+
} else if (direction === '180deg') {
|
|
88
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom') // default value
|
|
89
|
+
} else if (direction === '270deg') {
|
|
90
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'left')
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
return nodes
|
|
@@ -358,7 +368,16 @@ class Gradient extends Value {
|
|
|
358
368
|
*/
|
|
359
369
|
old(prefix) {
|
|
360
370
|
if (prefix === '-webkit-') {
|
|
361
|
-
let type
|
|
371
|
+
let type
|
|
372
|
+
if (this.name === 'linear-gradient') {
|
|
373
|
+
type = 'linear'
|
|
374
|
+
} else if (this.name === 'repeating-linear-gradient') {
|
|
375
|
+
type = 'repeating-linear'
|
|
376
|
+
} else if (this.name === 'repeating-radial-gradient') {
|
|
377
|
+
type = 'repeating-radial'
|
|
378
|
+
} else {
|
|
379
|
+
type = 'radial'
|
|
380
|
+
}
|
|
362
381
|
let string = '-gradient'
|
|
363
382
|
let regexp = utils.regexp(
|
|
364
383
|
`-webkit-(${type}-gradient|gradient\\(\\s*${type})`,
|
|
@@ -403,7 +422,7 @@ Gradient.names = [
|
|
|
403
422
|
]
|
|
404
423
|
|
|
405
424
|
Gradient.directions = {
|
|
406
|
-
top: 'bottom',
|
|
425
|
+
top: 'bottom', // default value
|
|
407
426
|
left: 'right',
|
|
408
427
|
bottom: 'top',
|
|
409
428
|
right: 'left'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoprefixer",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.12",
|
|
4
4
|
"description": "Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^10 || ^12 || >=14"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"postcss": "^8.1.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"browserslist": "^4.21.
|
|
39
|
-
"caniuse-lite": "^1.0.
|
|
38
|
+
"browserslist": "^4.21.4",
|
|
39
|
+
"caniuse-lite": "^1.0.30001407",
|
|
40
40
|
"fraction.js": "^4.2.0",
|
|
41
41
|
"normalize-range": "^0.1.2",
|
|
42
42
|
"picocolors": "^1.0.0",
|