source: trip-planner-front/node_modules/postcss-normalize-display-values/dist/index.js@ fa375fe

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
9
10var _cssnanoUtils = require("cssnano-utils");
11
12var _map = _interopRequireDefault(require("./lib/map"));
13
14function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16function transform(value) {
17 const {
18 nodes
19 } = (0, _postcssValueParser.default)(value);
20
21 if (nodes.length === 1) {
22 return value;
23 }
24
25 const values = nodes.filter((list, index) => index % 2 === 0).filter(node => node.type === 'word').map(n => n.value.toLowerCase());
26
27 if (values.length === 0) {
28 return value;
29 }
30
31 const match = (0, _cssnanoUtils.getMatch)(_map.default)(values);
32
33 if (!match) {
34 return value;
35 }
36
37 return match;
38}
39
40function pluginCreator() {
41 return {
42 postcssPlugin: 'postcss-normalize-display-values',
43
44 prepare() {
45 const cache = {};
46 return {
47 OnceExit(css) {
48 css.walkDecls(/^display$/i, decl => {
49 const value = decl.value;
50
51 if (!value) {
52 return;
53 }
54
55 if (cache[value]) {
56 decl.value = cache[value];
57 return;
58 }
59
60 const result = transform(value);
61 decl.value = result;
62 cache[value] = result;
63 });
64 }
65
66 };
67 }
68
69 };
70}
71
72pluginCreator.postcss = true;
73var _default = pluginCreator;
74exports.default = _default;
75module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.