postcss-normalize-timing-functions 4.0.0-rc.0 → 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/README.md +1 -1
- package/dist/index.js +35 -13
- package/package.json +8 -8
- package/CHANGELOG.md +0 -4
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,10 +20,8 @@ var _map2 = _interopRequireDefault(_map);
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return parseFloat(node.value);
|
|
26
|
-
};
|
|
23
|
+
const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default);
|
|
24
|
+
const getValue = node => parseFloat(node.value);
|
|
27
25
|
|
|
28
26
|
function evenValues(list, index) {
|
|
29
27
|
return index % 2 === 0;
|
|
@@ -33,38 +31,62 @@ function reduce(node) {
|
|
|
33
31
|
if (node.type !== 'function') {
|
|
34
32
|
return false;
|
|
35
33
|
}
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
const lowerCasedValue = node.value.toLowerCase();
|
|
36
|
+
|
|
37
|
+
if (lowerCasedValue === 'steps') {
|
|
37
38
|
// Don't bother checking the step-end case as it has the same length
|
|
38
39
|
// as steps(1)
|
|
39
|
-
if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value === 'start') {
|
|
40
|
+
if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value.toLowerCase() === 'start') {
|
|
40
41
|
node.type = 'word';
|
|
41
42
|
node.value = 'step-start';
|
|
43
|
+
|
|
42
44
|
delete node.nodes;
|
|
45
|
+
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
48
|
+
|
|
45
49
|
// The end case is actually the browser default, so it isn't required.
|
|
46
|
-
if (node.nodes[2] && node.nodes[2].value === 'end') {
|
|
50
|
+
if (node.nodes[2] && node.nodes[2].value.toLowerCase() === 'end') {
|
|
47
51
|
node.nodes = [node.nodes[0]];
|
|
52
|
+
|
|
48
53
|
return;
|
|
49
54
|
}
|
|
55
|
+
|
|
50
56
|
return false;
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
|
|
59
|
+
if (lowerCasedValue === 'cubic-bezier') {
|
|
60
|
+
const match = getMatch(node.nodes.filter(evenValues).map(getValue));
|
|
54
61
|
|
|
55
62
|
if (match) {
|
|
56
63
|
node.type = 'word';
|
|
57
64
|
node.value = match;
|
|
65
|
+
|
|
58
66
|
delete node.nodes;
|
|
67
|
+
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions',
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions', () => {
|
|
74
|
+
return css => {
|
|
75
|
+
const cache = {};
|
|
76
|
+
|
|
77
|
+
css.walkDecls(/(animation|transition)(-timing-function|$)/i, decl => {
|
|
78
|
+
const value = decl.value;
|
|
79
|
+
|
|
80
|
+
if (cache[value]) {
|
|
81
|
+
decl.value = cache[value];
|
|
82
|
+
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString();
|
|
87
|
+
|
|
88
|
+
decl.value = result;
|
|
89
|
+
cache[value] = result;
|
|
68
90
|
});
|
|
69
91
|
};
|
|
70
92
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-timing-functions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Normalize CSS animation/transition timing functions.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"cssnano-util-get-match": "^4.0.0
|
|
16
|
-
"postcss": "^
|
|
15
|
+
"cssnano-util-get-match": "^4.0.0",
|
|
16
|
+
"postcss": "^7.0.0",
|
|
17
17
|
"postcss-value-parser": "^3.0.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"babel-cli": "^6.0.0",
|
|
21
|
-
"cross-env": "^
|
|
21
|
+
"cross-env": "^5.0.0"
|
|
22
22
|
},
|
|
23
23
|
"author": {
|
|
24
24
|
"name": "Ben Briggs",
|
|
25
25
|
"email": "beneb.info@gmail.com",
|
|
26
26
|
"url": "http://beneb.info"
|
|
27
27
|
},
|
|
28
|
-
"repository": "
|
|
28
|
+
"repository": "cssnano/cssnano",
|
|
29
29
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
30
|
+
"url": "https://github.com/cssnano/cssnano/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/
|
|
32
|
+
"homepage": "https://github.com/cssnano/cssnano",
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">=6.9.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/CHANGELOG.md
DELETED