This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/postcss-reduce-initial/dist/index.js
2019-08-11 20:48:02 +02:00

58 lines
No EOL
1.7 KiB
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _postcss = require('postcss');
var _has = require('has');
var _has2 = _interopRequireDefault(_has);
var _browserslist = require('browserslist');
var _browserslist2 = _interopRequireDefault(_browserslist);
var _caniuseApi = require('caniuse-api');
var _fromInitial = require('../data/fromInitial.json');
var _fromInitial2 = _interopRequireDefault(_fromInitial);
var _toInitial = require('../data/toInitial.json');
var _toInitial2 = _interopRequireDefault(_toInitial);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const initial = 'initial';
exports.default = (0, _postcss.plugin)('postcss-reduce-initial', () => {
return (css, result) => {
const resultOpts = result.opts || {};
const browsers = (0, _browserslist2.default)(null, {
stats: resultOpts.stats,
path: __dirname,
env: resultOpts.env
});
const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
css.walkDecls(decl => {
const lowerCasedProp = decl.prop.toLowerCase();
if (initialSupport && (0, _has2.default)(_toInitial2.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial2.default[lowerCasedProp]) {
decl.value = initial;
return;
}
if (decl.value.toLowerCase() !== initial || !_fromInitial2.default[lowerCasedProp]) {
return;
}
decl.value = _fromInitial2.default[lowerCasedProp];
});
};
});
module.exports = exports['default'];