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

postcss-minify-selectors

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-minify-selectors - npm Package Compare versions

Comparing version

to
2.1.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 2.1.0
* Adds support for converting between similar `:nth-child` selectors. For
example, `:nth-child(1)` can be converted to `:first-child`, and
`p:nth-last-child(2n + 1)` converts to `p:nth-last-child(odd)`.
# 2.0.7

@@ -2,0 +8,0 @@

@@ -55,3 +55,35 @@ 'use strict';

var pseudoReplacements = {
':nth-child': ':first-child',
':nth-of-type': ':first-of-type',
':nth-last-child': ':last-child',
':nth-last-of-type': ':last-of-type'
};
function pseudo(selector) {
if (selector.nodes.length === 1 && pseudoReplacements[selector.value]) {
var first = selector.at(0);
var one = first.at(0);
if (first.length === 1) {
if (one.value === '1') {
selector.replaceWith(_postcssSelectorParser2.default.pseudo({
value: pseudoReplacements[selector.value]
}));
}
if (one.value === 'even') {
one.value = '2n';
}
}
if (first.length === 3) {
var two = first.at(1);
var three = first.at(2);
if (one.value === '2n' && two.value === '+' && three.value === '1') {
one.value = 'odd';
two.remove();
three.remove();
}
}
return;
}
var uniques = [];

@@ -58,0 +90,0 @@ selector.walk(function (child) {

6

package.json
{
"name": "postcss-minify-selectors",
"version": "2.0.7",
"version": "2.1.0",
"description": "Minify selectors with PostCSS.",

@@ -27,3 +27,3 @@ "main": "dist/index.js",

"devDependencies": {
"ava": "^0.16.0",
"ava": "^0.17.0",
"babel-cli": "^6.3.17",

@@ -41,3 +41,3 @@ "babel-core": "^6.3.26",

"eslint-plugin-import": "^2.0.1",
"nyc": "^8.4.0",
"nyc": "^10.0.0",
"postcss-font-magician": "^1.4.0"

@@ -44,0 +44,0 @@ },