postcss-minify-selectors
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,6 @@ | ||
# 1.2.0 | ||
* Does not touch quoted values in attribute selectors. | ||
* No longer will mangle values such as `2100%` in keyframes. | ||
# 1.1.0 | ||
@@ -2,0 +7,0 @@ |
34
index.js
@@ -9,2 +9,3 @@ 'use strict'; | ||
var natural = require('javascript-natural-sort'); | ||
var roq = require('./lib/replaceOutsideQuotes'); | ||
@@ -23,11 +24,12 @@ function uniq (params, map) { | ||
selector = uniq(selector, true).map(function (sel) { | ||
// Trim consecutive spaces | ||
sel = sel.replace(/(?=\S*?)(\s+)(?=\S)/, ' '); | ||
// Remove the star from *qualified* star selectors | ||
// TODO: Improve the parsing here - currently it just skips the selector | ||
// if there is a comment. | ||
if (!~sel.indexOf('/*') && !~sel.indexOf('*/')) { | ||
return sel.replace(/(\*)([^\+~=>\s])/g, '$2'); | ||
} | ||
return sel; | ||
return roq(sel, function (range) { | ||
// Remove the star from *qualified* star selectors | ||
// TODO: Improve the parsing here - currently it just skips the selector | ||
// if there is a comment. | ||
range = range.replace(/(?=\S*?)(\s+)(?=\S)/, ' '); | ||
if (!~range.indexOf('/*') && !~range.indexOf('*/')) { | ||
return range.replace(/(\*)([^\+~=>\s])/g, '$2'); | ||
} | ||
return range; | ||
}); | ||
}).map(minAttributes).join(','); | ||
@@ -45,6 +47,16 @@ // Trim any useless space inside negation pseudo classes | ||
if (rule.parent.type !== 'root' && ~rule.parent.name.indexOf('keyframes')) { | ||
selector = selector.replace('from', '0%').replace('100%', 'to'); | ||
selector = list.comma(selector).map(function (value) { | ||
if (value === 'from') { | ||
return '0%'; | ||
} | ||
if (value === '100%') { | ||
return 'to'; | ||
} | ||
return value; | ||
}).join(','); | ||
} | ||
// Trim whitespace around selector combinators | ||
rule.selector = selector.replace(/\s*([>+~])\s*/g, '$1'); | ||
rule.selector = roq(selector, function (range) { | ||
return range.replace(/\s*([>+~])\s*/g, '$1'); | ||
}); | ||
} | ||
@@ -51,0 +63,0 @@ |
{ | ||
"name": "postcss-minify-selectors", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Minify selectors with PostCSS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8779
9
155