postcss-unique-selectors 5.0.3 → 5.0.4
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/package.json +3 -7
- package/{dist → src}/index.js +9 -21
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-unique-selectors",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Ensure CSS selectors are unique.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"LICENSE-MIT",
|
|
8
|
-
"
|
|
8
|
+
"src"
|
|
9
9
|
],
|
|
10
10
|
"keywords": [
|
|
11
11
|
"css",
|
|
@@ -35,9 +35,5 @@
|
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"postcss": "^8.2.15"
|
|
37
37
|
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"prebuild": "rimraf dist",
|
|
40
|
-
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
|
|
41
|
-
},
|
|
42
38
|
"readme": "# [postcss][postcss]-unique-selectors\n\n> Ensure CSS selectors are unique.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-unique-selectors) do:\n\n```\nnpm install postcss-unique-selectors --save\n```\n\n## Example\n\nSelectors are sorted naturally, and deduplicated:\n\n### Input\n\n```css\nh1,h3,h2,h1 {\n color: red\n}\n```\n\n### Output\n\n```css\nh1,h2,h3 {\n color: red\n}\n```\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
|
|
43
39
|
}
|
package/{dist → src}/index.js
RENAMED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
'use strict';
|
|
2
|
+
const selectorParser = require('postcss-selector-parser');
|
|
11
3
|
|
|
12
4
|
function parseSelectors(selectors, callback) {
|
|
13
|
-
return (
|
|
5
|
+
return selectorParser(callback).processSync(selectors);
|
|
14
6
|
}
|
|
15
7
|
|
|
16
8
|
function unique(rule) {
|
|
@@ -22,30 +14,26 @@ function unique(rule) {
|
|
|
22
14
|
function pluginCreator() {
|
|
23
15
|
return {
|
|
24
16
|
postcssPlugin: 'postcss-unique-selectors',
|
|
25
|
-
|
|
26
17
|
OnceExit(css) {
|
|
27
|
-
css.walkRules(nodes => {
|
|
18
|
+
css.walkRules((nodes) => {
|
|
28
19
|
let comments = [];
|
|
29
|
-
nodes.selector = parseSelectors(nodes.selector, selNode => {
|
|
30
|
-
selNode.walk(sel => {
|
|
20
|
+
nodes.selector = parseSelectors(nodes.selector, (selNode) => {
|
|
21
|
+
selNode.walk((sel) => {
|
|
31
22
|
if (sel.type === 'comment') {
|
|
32
23
|
comments.push(sel.value);
|
|
33
24
|
sel.remove();
|
|
34
25
|
return;
|
|
35
26
|
} else {
|
|
36
|
-
return
|
|
27
|
+
return;
|
|
37
28
|
}
|
|
38
29
|
});
|
|
39
30
|
});
|
|
40
31
|
unique(nodes);
|
|
41
32
|
nodes.selectors = nodes.selectors.concat(comments);
|
|
42
33
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
34
|
+
},
|
|
45
35
|
};
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
pluginCreator.postcss = true;
|
|
49
|
-
|
|
50
|
-
exports.default = _default;
|
|
51
|
-
module.exports = exports.default;
|
|
39
|
+
module.exports = pluginCreator;
|