Skip to content

Commit

Permalink
Trim Custom Property values when possible (fixes #393)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Nov 26, 2020
1 parent c3cd5ed commit 0f2bd49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## next

- Trim Custom Property values when possible (#393)
- Fixed removing unit for zero-length dimentions in `min()`, `max()` and `clamp()` functions (#426)
- Fixed crash on bad value in TRBL declaration value (#412)

Expand Down
9 changes: 9 additions & 0 deletions lib/clean/Declaration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var property = require('css-tree').property;

module.exports = function cleanDeclartion(node, item, list) {
if (node.value.children && node.value.children.isEmpty()) {
list.remove(item);
return;
}

if (property(node.property).custom) {
if (/\S/.test(node.value.value)) {
node.value.value = node.value.value.trim();
}
}
};
2 changes: 1 addition & 1 deletion test/fixture/compress/custom-property.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f2bd49

Please sign in to comment.