postcss-minify-selectors
Advanced tools
Comparing version 1.5.0 to 2.0.0
@@ -0,1 +1,7 @@ | ||
# 2.0.0 | ||
* Upgraded to PostCSS 5. | ||
* At-rule parameter minification was extracted out of this module into | ||
postcss-minify-params (thanks to @TrySound). | ||
# 1.5.0 | ||
@@ -2,0 +8,0 @@ |
25
index.js
'use strict'; | ||
var uniqs = require('uniqs'); | ||
var postcss = require('postcss'); | ||
var comma = postcss.list.comma; | ||
var normalize = require('normalize-selector'); | ||
var natural = require('javascript-natural-sort'); | ||
@@ -13,17 +10,2 @@ var unquote = require('./lib/unquote'); | ||
function uniq (params, map) { | ||
var transform = uniqs(comma(params).map(function (selector) { | ||
// Join selectors that are split over new lines | ||
return selector.replace(/\\\n/g, ''); | ||
})).sort(natural); | ||
return map ? transform : transform.join(','); | ||
} | ||
function optimiseAtRule (rule) { | ||
if (!rule.params) { | ||
return; | ||
} | ||
rule.params = normalize(uniq(rule.params)); | ||
} | ||
function getParsed (selectors, callback) { | ||
@@ -51,3 +33,3 @@ return parser(callback).process(selectors).result; | ||
function optimise (rule) { | ||
var selector = rule._selector && rule._selector.raw || rule.selector; | ||
var selector = rule.raws.selector && rule.raws.selector.raw || rule.selector; | ||
rule.selector = getParsed(selector, function (selectors) { | ||
@@ -116,7 +98,6 @@ selectors.nodes.sort(function (a, b) { | ||
return function (css) { | ||
css.eachInside(function (node) { | ||
if (node.type === 'rule') { return optimise(node); } | ||
if (node.type === 'atrule') { return optimiseAtRule(node); } | ||
css.walkRules(function (rule) { | ||
return optimise(rule); | ||
}); | ||
}; | ||
}); |
{ | ||
"name": "postcss-minify-selectors", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"description": "Minify selectors with PostCSS.", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"postcss-font-magician": "^1.3.0", | ||
"tap-spec": "^4.0.2", | ||
"tape": "^4.1.0" | ||
"tap-spec": "^4.1.0", | ||
"tape": "^4.2.0" | ||
}, | ||
@@ -39,7 +39,5 @@ "homepage": "https://github.com/ben-eb/postcss-minify-selectors", | ||
"javascript-natural-sort": "^0.7.1", | ||
"normalize-selector": "^0.2.0", | ||
"postcss": "^4.1.16", | ||
"postcss-selector-parser": "^1.1.2", | ||
"uniqs": "^2.0.0" | ||
"postcss": "^5.0.4", | ||
"postcss-selector-parser": "^1.1.4" | ||
} | ||
} |
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
3
8529
97
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedjs-base64@2.6.4(transitive)
+ Addedpostcss@5.2.18(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.03.2.3(transitive)
- Removednormalize-selector@^0.2.0
- Removeduniqs@^2.0.0
- Removedamdefine@1.0.1(transitive)
- Removedes6-promise@2.3.0(transitive)
- Removedjs-base64@2.1.9(transitive)
- Removednormalize-selector@0.2.0(transitive)
- Removedpostcss@4.1.16(transitive)
- Removedsource-map@0.4.4(transitive)
- Removeduniqs@2.0.0(transitive)
Updatedpostcss@^5.0.4