postcss-minify-params 4.0.1 → 4.0.2
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/dist/index.js +10 -5
- package/package.json +1 -1
- package/CHANGELOG.md +0 -36
package/dist/index.js
CHANGED
|
@@ -55,11 +55,10 @@ function removeNode(node) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function transform(legacy, rule) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
if (!rule.params || rule.name.toLowerCase() === 'value') {
|
|
58
|
+
const ruleName = rule.name.toLowerCase();
|
|
59
|
+
|
|
60
|
+
// We should re-arrange parameters only for `@media` and `@supports` at-rules
|
|
61
|
+
if (!rule.params || !["media", "supports"].includes(ruleName)) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -68,8 +67,10 @@ function transform(legacy, rule) {
|
|
|
68
67
|
params.walk((node, index) => {
|
|
69
68
|
if (node.type === 'div' || node.type === 'function') {
|
|
70
69
|
node.before = node.after = '';
|
|
70
|
+
|
|
71
71
|
if (node.type === 'function' && node.nodes[4] && node.nodes[0].value.toLowerCase().indexOf('-aspect-ratio') === 3) {
|
|
72
72
|
const [a, b] = aspectRatio(node.nodes[2].value, node.nodes[4].value);
|
|
73
|
+
|
|
73
74
|
node.nodes[2].value = a;
|
|
74
75
|
node.nodes[4].value = b;
|
|
75
76
|
}
|
|
@@ -77,14 +78,18 @@ function transform(legacy, rule) {
|
|
|
77
78
|
node.value = ' ';
|
|
78
79
|
} else {
|
|
79
80
|
const prevWord = params.nodes[index - 2];
|
|
81
|
+
|
|
80
82
|
if (node.value.toLowerCase() === 'all' && rule.name.toLowerCase() === 'media' && !prevWord) {
|
|
81
83
|
const nextWord = params.nodes[index + 2];
|
|
84
|
+
|
|
82
85
|
if (!legacy || nextWord) {
|
|
83
86
|
removeNode(node);
|
|
84
87
|
}
|
|
88
|
+
|
|
85
89
|
if (nextWord && nextWord.value.toLowerCase() === 'and') {
|
|
86
90
|
const nextSpace = params.nodes[index + 1];
|
|
87
91
|
const secondSpace = params.nodes[index + 3];
|
|
92
|
+
|
|
88
93
|
removeNode(nextWord);
|
|
89
94
|
removeNode(nextSpace);
|
|
90
95
|
removeNode(secondSpace);
|
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Head
|
|
2
|
-
|
|
3
|
-
* Resolves an issue with mangling css-modules' `@value` at-rule.
|
|
4
|
-
|
|
5
|
-
# 4.0.0-rc.0
|
|
6
|
-
|
|
7
|
-
* Breaking: Drops support for Node 0.12, we now require at least Node 4.
|
|
8
|
-
* Breaking: Update PostCSS to 6.0.0.
|
|
9
|
-
|
|
10
|
-
# 1.2.2
|
|
11
|
-
|
|
12
|
-
* Resolves an issue where `all and` would be removed from
|
|
13
|
-
`@media not all and (conditions) {}`, causing an invalid media query to
|
|
14
|
-
be output.
|
|
15
|
-
|
|
16
|
-
# 1.2.1
|
|
17
|
-
|
|
18
|
-
* Resolves an issue where `1.2.0` would throw on empty function parentheses.
|
|
19
|
-
|
|
20
|
-
# 1.2.0
|
|
21
|
-
|
|
22
|
-
* Adds support for simplifying `min-aspect-ratio` and `max-aspect-ratio`. For
|
|
23
|
-
example, `@media (min-aspect-ratio: 1280/720) {}` can be minified to
|
|
24
|
-
`@media (min-aspect-ratio:16/9){}`.
|
|
25
|
-
|
|
26
|
-
# 1.1.0
|
|
27
|
-
|
|
28
|
-
* Adds support for removing the unnecessary `all and` from media queries.
|
|
29
|
-
|
|
30
|
-
# 1.0.1
|
|
31
|
-
|
|
32
|
-
* Refactor to ES6.
|
|
33
|
-
|
|
34
|
-
# 1.0.0
|
|
35
|
-
|
|
36
|
-
* Initial release.
|