🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-ordered-values

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-ordered-values - npm Package Compare versions

Comparing version

to
4.1.2

43

dist/index.js

@@ -11,5 +11,5 @@ 'use strict';

var _getParsed = require('./lib/getParsed');
var _postcssValueParser = require('postcss-value-parser');
var _getParsed2 = _interopRequireDefault(_getParsed);
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);

@@ -60,23 +60,56 @@ var _animation = require('./rules/animation');

let abort = false;
parsed.walk(({ type, value }) => {
if (type === 'comment' || type === 'function' && value.toLowerCase() === 'var' || type === 'word' && ~value.indexOf(`___CSS_LOADER_IMPORT___`)) {
abort = true;
return false;
}
});
return abort;
}
function getValue(decl) {
let { value, raws } = decl;
if (raws && raws.value && raws.value.raw) {
value = raws.value.raw;
}
return value;
}
exports.default = _postcss2.default.plugin('postcss-ordered-values', () => {
return css => {
const cache = {};
css.walkDecls(decl => {
const processor = rules[decl.prop.toLowerCase()];
const lowerCasedProp = decl.prop.toLowerCase();
const processor = rules[lowerCasedProp];
if (!processor) {
return;
}
const parsed = (0, _getParsed2.default)(decl);
const value = getValue(decl);
if (cache[value]) {
decl.value = cache[value];
return;
}
const parsed = (0, _postcssValueParser2.default)(value);
if (parsed.nodes.length < 2 || shouldAbort(parsed)) {
cache[value] = value;
return;
}
processor(decl, parsed);
const result = processor(parsed);
decl.value = result;
cache[value] = result;
});

@@ -83,0 +116,0 @@ };

@@ -19,2 +19,3 @@ 'use strict';

});
if (index !== values.length - 1) {

@@ -24,2 +25,3 @@ nodes[nodes.length - 1].type = 'div';

}
return nodes;

@@ -26,0 +28,0 @@ }, [])

@@ -29,2 +29,3 @@ 'use strict';

const keywords = ['ease', 'ease-in', 'ease-in-out', 'ease-out', 'linear', 'step-end', 'step-start'];
return type === 'function' && functions.includes(value) || keywords.includes(value);

@@ -47,2 +48,3 @@ };

const quantity = (0, _postcssValueParser.unit)(value);
return quantity && ['ms', 's'].includes(quantity.unit);

@@ -53,6 +55,7 @@ };

const quantity = (0, _postcssValueParser.unit)(value);
return value === 'infinite' || quantity && !quantity.unit;
};
function normalizeAnimation(decl, parsed) {
function normalizeAnimation(parsed) {
const args = (0, _cssnanoUtilGetArguments2.default)(parsed);

@@ -72,8 +75,12 @@

const stateConditions = [{ property: 'duration', delegate: isTime }, { property: 'timingFunction', delegate: isTimingFunction }, { property: 'delay', delegate: isTime }, { property: 'iterationCount', delegate: isIterationCount }, { property: 'direction', delegate: isDirection }, { property: 'fillMode', delegate: isFillMode }, { property: 'playState', delegate: isPlayState }];
arg.forEach(node => {
let { type, value } = node;
if (type === 'space') {
return;
}
value = value.toLowerCase();
const hasMatch = stateConditions.some(({ property, delegate }) => {

@@ -85,2 +92,3 @@ if (delegate(value, type) && !state[property].length) {

});
if (!hasMatch) {

@@ -93,4 +101,4 @@ state.name = [...state.name, node, (0, _addSpace2.default)()];

decl.value = (0, _getValue2.default)(values);
return (0, _getValue2.default)(values);
};
module.exports = exports['default'];

6

dist/rules/border.js

@@ -18,4 +18,5 @@ 'use strict';

function normalizeBorder(decl, border) {
function normalizeBorder(border) {
const order = { width: '', style: '', color: '' };
border.walk(node => {

@@ -48,4 +49,5 @@ const { type, value } = node;

});
decl.value = `${order.width} ${order.style} ${order.color}`.trim();
return `${order.width} ${order.style} ${order.color}`.trim();
};
module.exports = exports['default'];

@@ -26,3 +26,3 @@ 'use strict';

function normalizeBoxShadow(decl, parsed) {
function normalizeBoxShadow(parsed) {
let args = (0, _cssnanoUtilGetArguments2.default)(parsed);

@@ -37,4 +37,6 @@ let abort = false;

};
arg.forEach(node => {
const { type, value } = node;
if (type === 'function' && ~value.toLowerCase().indexOf('calc')) {

@@ -44,5 +46,7 @@ abort = true;

}
if (type === 'space') {
return;
}
if ((0, _postcssValueParser.unit)(value)) {

@@ -56,2 +60,3 @@ val = [...val, node, (0, _addSpace2.default)()];

});
return [...list, [...state.inset, ...val, ...state.color]];

@@ -61,7 +66,7 @@ }, []);

if (abort) {
return;
return parsed.toString();
}
decl.value = (0, _getValue2.default)(values);
return (0, _getValue2.default)(values);
}
module.exports = exports['default'];

@@ -13,3 +13,3 @@ 'use strict';

function normalizeFlexFlow(decl, flexFlow) {
function normalizeFlexFlow(flexFlow) {
let order = {

@@ -19,2 +19,3 @@ direction: '',

};
flexFlow.walk(({ value }) => {

@@ -25,9 +26,12 @@ if (~flexDirection.indexOf(value.toLowerCase())) {

}
if (~flexWrap.indexOf(value.toLowerCase())) {
order.wrap = value;
return;
}
});
decl.value = `${order.direction} ${order.wrap}`.trim();
return `${order.direction} ${order.wrap}`.trim();
};
module.exports = exports['default'];

@@ -28,3 +28,3 @@ 'use strict';

function normalizeTransition(decl, parsed) {
function normalizeTransition(parsed) {
let args = (0, _cssnanoUtilGetArguments2.default)(parsed);

@@ -39,7 +39,10 @@

};
arg.forEach(node => {
const { type, value } = node;
if (type === 'space') {
return;
}
if (type === 'function' && ~['steps', 'cubic-bezier'].indexOf(value.toLowerCase())) {

@@ -59,7 +62,8 @@ state.timingFunction = [...state.timingFunction, node, (0, _addSpace2.default)()];

});
return [...list, [...state.property, ...state.time1, ...state.timingFunction, ...state.time2]];
}, []);
decl.value = (0, _getValue2.default)(values);
return (0, _getValue2.default)(values);
}
module.exports = exports['default'];
{
"name": "postcss-ordered-values",
"version": "4.1.1",
"version": "4.1.2",
"description": "Ensure values are ordered consistently in your CSS.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",