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

Last change on this file since 76712b2 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

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