source: trip-planner-front/node_modules/postcss-unique-selectors/dist/index.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _alphanumSort = _interopRequireDefault(require("alphanum-sort"));
9
10var _uniqs = _interopRequireDefault(require("uniqs"));
11
12var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
13
14function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16function parseSelectors(selectors, callback) {
17 return (0, _postcssSelectorParser.default)(callback).processSync(selectors);
18}
19
20function unique(rule) {
21 rule.selector = (0, _alphanumSort.default)((0, _uniqs.default)(rule.selectors), {
22 insensitive: true
23 }).join();
24}
25
26function pluginCreator() {
27 return {
28 postcssPlugin: 'postcss-unique-selectors',
29
30 OnceExit(css) {
31 css.walkRules(nodes => {
32 let comments = [];
33 nodes.selector = parseSelectors(nodes.selector, selNode => {
34 selNode.walk(sel => {
35 if (sel.type === 'comment') {
36 comments.push(sel.value);
37 sel.remove();
38 return;
39 } else {
40 return sel;
41 }
42 });
43 });
44 unique(nodes);
45 nodes.selectors = nodes.selectors.concat(comments);
46 });
47 }
48
49 };
50}
51
52pluginCreator.postcss = true;
53var _default = pluginCreator;
54exports.default = _default;
55module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.