source: trip-planner-front/node_modules/postcss-reduce-initial/dist/index.js@ 571e0df

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

initial commit

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _browserslist = _interopRequireDefault(require("browserslist"));
9
10var _caniuseApi = require("caniuse-api");
11
12var _fromInitial = _interopRequireDefault(require("../data/fromInitial.json"));
13
14var _toInitial = _interopRequireDefault(require("../data/toInitial.json"));
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18const initial = 'initial'; // In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
19
20const defaultIgnoreProps = ['writing-mode'];
21
22function pluginCreator() {
23 return {
24 postcssPlugin: 'postcss-reduce-initial',
25
26 prepare(result) {
27 const resultOpts = result.opts || {};
28 const browsers = (0, _browserslist.default)(null, {
29 stats: resultOpts.stats,
30 path: __dirname,
31 env: resultOpts.env
32 });
33 const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
34 return {
35 OnceExit(css) {
36 css.walkDecls(decl => {
37 const lowerCasedProp = decl.prop.toLowerCase();
38 const ignoreProp = defaultIgnoreProps.concat(resultOpts.ignore || []);
39
40 if (ignoreProp.includes(lowerCasedProp)) {
41 return;
42 }
43
44 if (initialSupport && Object.prototype.hasOwnProperty.call(_toInitial.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial.default[lowerCasedProp]) {
45 decl.value = initial;
46 return;
47 }
48
49 if (decl.value.toLowerCase() !== initial || !_fromInitial.default[lowerCasedProp]) {
50 return;
51 }
52
53 decl.value = _fromInitial.default[lowerCasedProp];
54 });
55 }
56
57 };
58 }
59
60 };
61}
62
63pluginCreator.postcss = true;
64var _default = pluginCreator;
65exports.default = _default;
66module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.