Sha256: 6d8e639aacf14e250f6aeeb4b8fff353519a5420bc48e36b7793ecf1ef1316cc

Contents?: true

Size: 1.55 KB

Versions: 26

Compression:

Stored size: 1.55 KB

Contents

'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.default = parseWsc;

var _postcss = require('postcss');

var _validateWsc = require('./validateWsc');

const none = /^\s*(none|medium)(\s+none(\s+(none|currentcolor))?)?\s*$/i;

const varRE = /(^.*var)(.*\(.*--.*\))(.*)/i;
const varPreserveCase = p => `${p[1].toLowerCase()}${p[2]}${p[3].toLowerCase()}`;
const toLower = v => {
    const match = varRE.exec(v);
    return match ? varPreserveCase(match) : v.toLowerCase();
};

function parseWsc(value) {
    if (none.test(value)) {
        return ['medium', 'none', 'currentcolor'];
    }

    let width, style, color;

    const values = _postcss.list.space(value);

    if (values.length > 1 && (0, _validateWsc.isStyle)(values[1]) && values[0].toLowerCase() === 'none') {
        values.unshift();
        width = '0';
    }

    const unknown = [];

    values.forEach(v => {
        if ((0, _validateWsc.isStyle)(v)) {
            style = toLower(v);
        } else if ((0, _validateWsc.isWidth)(v)) {
            width = toLower(v);
        } else if ((0, _validateWsc.isColor)(v)) {
            color = toLower(v);
        } else {
            unknown.push(v);
        }
    });

    if (unknown.length) {
        if (!width && style && color) {
            width = unknown.pop();
        }

        if (width && !style && color) {
            style = unknown.pop();
        }

        if (width && style && !color) {
            color = unknown.pop();
        }
    }

    return [width, style, color];
}
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-merge-longhand/dist/lib/parseWsc.js
disco_app-0.18.0 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.18.2 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.16.1 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.15.2 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.18.4 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.18.1 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.14.0 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
tang-0.2.1 spec/tang_app/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
tang-0.2.0 spec/tang_app/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
tang-0.1.0 spec/tang_app/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
tang-0.0.9 spec/tang_app/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
enju_library-0.3.8 spec/dummy/node_modules/postcss-merge-longhand/dist/lib/parseWsc.js
jester-data-8.0.0 node_modules/postcss-merge-longhand/dist/lib/parseWsc.js