Sha256: 91e137125e62c6e3d5f3fbd6a892b30d26c28fc303b61aa3420735d8a63cdb48

Contents?: true

Size: 1.65 KB

Versions: 26

Compression:

Stored size: 1.65 KB

Contents

'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'];

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.18.0 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.18.2 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.16.1 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.15.2 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.18.4 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.18.1 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.14.0 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/postcss-reduce-initial/dist/index.js
tang-0.2.1 spec/tang_app/node_modules/postcss-reduce-initial/dist/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/postcss-reduce-initial/dist/index.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/postcss-reduce-initial/dist/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/postcss-reduce-initial/dist/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/postcss-reduce-initial/dist/index.js
tang-0.2.0 spec/tang_app/node_modules/postcss-reduce-initial/dist/index.js
tang-0.1.0 spec/tang_app/node_modules/postcss-reduce-initial/dist/index.js
tang-0.0.9 spec/tang_app/node_modules/postcss-reduce-initial/dist/index.js
enju_library-0.3.8 spec/dummy/node_modules/postcss-reduce-initial/dist/index.js
jester-data-8.0.0 node_modules/postcss-reduce-initial/dist/index.js