postcss-normalize-repeat-style 4.0.0-rc.2 → 4.0.0
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 +14 -20
- package/package.json +8 -8
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,27 +30,25 @@ function evenValues(list, index) {
|
|
|
30
30
|
return index % 2 === 0;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
return mapping[0];
|
|
35
|
-
});
|
|
33
|
+
const repeatKeywords = _map2.default.map(mapping => mapping[0]);
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default);
|
|
38
36
|
|
|
39
37
|
function transform(decl) {
|
|
40
|
-
|
|
38
|
+
const values = (0, _postcssValueParser2.default)(decl.value);
|
|
41
39
|
if (values.nodes.length === 1) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
args.forEach(
|
|
42
|
+
const args = (0, _cssnanoUtilGetArguments2.default)(values);
|
|
43
|
+
const relevant = [];
|
|
44
|
+
args.forEach(arg => {
|
|
47
45
|
relevant.push({
|
|
48
46
|
start: null,
|
|
49
47
|
end: null
|
|
50
48
|
});
|
|
51
|
-
arg.forEach(
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
arg.forEach((part, index) => {
|
|
50
|
+
const isRepeat = ~repeatKeywords.indexOf(part.value.toLowerCase());
|
|
51
|
+
const len = relevant.length - 1;
|
|
54
52
|
if (relevant[len].start === null && isRepeat) {
|
|
55
53
|
relevant[len].start = index;
|
|
56
54
|
relevant[len].end = index;
|
|
@@ -67,17 +65,15 @@ function transform(decl) {
|
|
|
67
65
|
}
|
|
68
66
|
});
|
|
69
67
|
});
|
|
70
|
-
relevant.forEach(
|
|
68
|
+
relevant.forEach((range, index) => {
|
|
71
69
|
if (range.start === null) {
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
74
|
-
|
|
72
|
+
const val = args[index].slice(range.start, range.end + 1);
|
|
75
73
|
if (val.length !== 3) {
|
|
76
74
|
return;
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
return n.value;
|
|
80
|
-
}));
|
|
76
|
+
const match = getMatch(val.filter(evenValues).map(n => n.value.toLowerCase()));
|
|
81
77
|
if (match) {
|
|
82
78
|
args[index][range.start].value = match;
|
|
83
79
|
args[index][range.start + 1].value = '';
|
|
@@ -87,9 +83,7 @@ function transform(decl) {
|
|
|
87
83
|
decl.value = values.toString();
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
exports.default = _postcss2.default.plugin('postcss-normalize-repeat-style',
|
|
91
|
-
return
|
|
92
|
-
return css.walkDecls(/background(-repeat)?|(-webkit-)?mask-repeat/, transform);
|
|
93
|
-
};
|
|
86
|
+
exports.default = _postcss2.default.plugin('postcss-normalize-repeat-style', () => {
|
|
87
|
+
return css => css.walkDecls(/background(-repeat)?|(-webkit-)?mask-repeat/i, transform);
|
|
94
88
|
});
|
|
95
89
|
module.exports = exports['default'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-repeat-style",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Convert two value syntax for repeat-style into one value.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,26 +12,26 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"cssnano-util-get-arguments": "^4.0.0
|
|
16
|
-
"cssnano-util-get-match": "^4.0.0
|
|
15
|
+
"cssnano-util-get-arguments": "^4.0.0",
|
|
16
|
+
"cssnano-util-get-match": "^4.0.0",
|
|
17
17
|
"postcss": "^6.0.0",
|
|
18
18
|
"postcss-value-parser": "^3.0.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"babel-cli": "^6.0.0",
|
|
22
|
-
"cross-env": "^
|
|
22
|
+
"cross-env": "^5.0.0"
|
|
23
23
|
},
|
|
24
24
|
"author": {
|
|
25
25
|
"name": "Ben Briggs",
|
|
26
26
|
"email": "beneb.info@gmail.com",
|
|
27
27
|
"url": "http://beneb.info"
|
|
28
28
|
},
|
|
29
|
-
"repository": "
|
|
29
|
+
"repository": "cssnano/cssnano",
|
|
30
30
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/
|
|
31
|
+
"url": "https://github.com/cssnano/cssnano/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
33
|
+
"homepage": "https://github.com/cssnano/cssnano",
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
35
|
+
"node": ">=6.9.0"
|
|
36
36
|
}
|
|
37
37
|
}
|