postcss-ordered-values
Advanced tools
Comparing version
@@ -0,1 +1,6 @@ | ||
# 2.1.1 | ||
* Fixes an issue where special comments were being discarded by this module. | ||
Now, property values with any comments in them will be ignored. | ||
# 2.1.0 | ||
@@ -2,0 +7,0 @@ |
@@ -27,2 +27,3 @@ 'use strict'; | ||
exports.default = _postcss2.default.plugin('postcss-ordered-values', function () { | ||
@@ -29,0 +30,0 @@ return function (css) { |
@@ -25,6 +25,16 @@ 'use strict'; | ||
} | ||
var value = decl.value; | ||
if (decl.raws && decl.raws.value && decl.raws.value.raw) { | ||
value = decl.raws.value.raw; | ||
} | ||
var order = { width: '', style: '', color: '' }; | ||
var border = (0, _postcssValueParser2.default)(decl.value); | ||
var border = (0, _postcssValueParser2.default)(value); | ||
var abort = false; | ||
if (border.nodes.length > 2) { | ||
border.walk(function (node) { | ||
if (node.type === 'comment') { | ||
abort = true; | ||
return false; | ||
} | ||
if (node.type === 'word') { | ||
@@ -51,5 +61,7 @@ if (~borderStyles.indexOf(node.value)) { | ||
}); | ||
decl.value = (order.width + ' ' + order.style + ' ' + order.color).trim(); | ||
if (!abort) { | ||
decl.value = (order.width + ' ' + order.style + ' ' + order.color).trim(); | ||
} | ||
} | ||
}; | ||
module.exports = exports['default']; |
@@ -29,3 +29,8 @@ 'use strict'; | ||
} | ||
var parsed = (0, _postcssValueParser2.default)(decl.value); | ||
var value = decl.value; | ||
if (decl.raws && decl.raws.value && decl.raws.value.raw) { | ||
value = decl.raws.value.raw; | ||
} | ||
var parsed = (0, _postcssValueParser2.default)(value); | ||
if (parsed.nodes.length < 2) { | ||
@@ -37,6 +42,7 @@ return; | ||
var values = []; | ||
var abort = false; | ||
args.forEach(function (arg) { | ||
values.push([]); | ||
var value = values[values.length - 1]; | ||
var val = values[values.length - 1]; | ||
var state = { | ||
@@ -47,2 +53,6 @@ inset: [], | ||
arg.forEach(function (node) { | ||
if (node.type === 'comment') { | ||
abort = true; | ||
return; | ||
} | ||
if (node.type === 'space') { | ||
@@ -52,4 +62,4 @@ return; | ||
if ((0, _postcssValueParser.unit)(node.value)) { | ||
value.push(node); | ||
value.push({ type: 'space', value: ' ' }); | ||
val.push(node); | ||
val.push({ type: 'space', value: ' ' }); | ||
} else if (node.value === 'inset') { | ||
@@ -63,5 +73,9 @@ state.inset.push(node); | ||
}); | ||
values[values.length - 1] = state.inset.concat(value).concat(state.color); | ||
values[values.length - 1] = state.inset.concat(val).concat(state.color); | ||
}); | ||
if (abort) { | ||
return; | ||
} | ||
decl.value = (0, _postcssValueParser.stringify)({ | ||
@@ -68,0 +82,0 @@ nodes: values.reduce(function (nodes, arg, index) { |
@@ -23,6 +23,16 @@ 'use strict'; | ||
} | ||
var value = decl.value; | ||
if (decl.raws && decl.raws.value && decl.raws.value.raw) { | ||
value = decl.raws.value.raw; | ||
} | ||
var order = { direction: '', wrap: '' }; | ||
var flexFlow = (0, _postcssValueParser2.default)(decl.value); | ||
var flexFlow = (0, _postcssValueParser2.default)(value); | ||
var abort = false; | ||
if (flexFlow.nodes.length > 2) { | ||
flexFlow.walk(function (node) { | ||
if (node.type === 'comment') { | ||
abort = true; | ||
return; | ||
} | ||
if (~flexDirection.indexOf(node.value)) { | ||
@@ -37,5 +47,7 @@ order.direction = node.value; | ||
}); | ||
decl.value = (order.direction + ' ' + order.wrap).trim(); | ||
if (!abort) { | ||
decl.value = (order.direction + ' ' + order.wrap).trim(); | ||
} | ||
} | ||
}; | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss-ordered-values", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Ensure values are ordered consistently in your CSS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12440
9.28%201
20.36%0
-100%