Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-minify-selectors

Package Overview
Dependencies
Maintainers
2
Versions
67
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 1.4.6 to 1.4.7

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 1.4.7
* Further performance improvements by using less postcss-selector-parser
iterations.
# 1.4.6

@@ -2,0 +7,0 @@

72

index.js

@@ -54,23 +54,20 @@ 'use strict';

});
selectors.eachAttribute(function (selector) {
if (selector.value) {
// Join selectors that are split over new lines
selector.value = selector.value.replace(/\\\n/g, '').trim();
if (canUnquote(selector.value)) {
selector.value = unquote(selector.value);
}
selector.operator = selector.operator.trim();
}
if (selector.raw) {
selector.raw.insensitive = '';
}
selector.attribute = selector.attribute.trim();
});
var uniques = [];
var uniqueSelectors = [];
selectors.eachInside(function (selector) {
var next = selector.next();
var toString = String(selector);
// Trim whitespace around the value
selector.spaces.before = selector.spaces.after = '';
// Minimise from/100%
if (selector.value === 'from' && selector.type === 'tag') { selector.value = '0%'; }
if (selector.value === '100%' && selector.type === 'tag') { selector.value = 'to'; }
if (selector.type === 'attribute') {
if (selector.value) {
// Join selectors that are split over new lines
selector.value = selector.value.replace(/\\\n/g, '').trim();
if (canUnquote(selector.value)) {
selector.value = unquote(selector.value);
}
selector.operator = selector.operator.trim();
}
if (selector.raw) { selector.raw.insensitive = ''; }
selector.attribute = selector.attribute.trim();
}
if (selector.type === 'combinator') {

@@ -80,5 +77,17 @@ var value = selector.value.trim();

}
if (selector.type === 'pseudo') {
var uniques = [];
selector.eachInside(function (child) {
if (child.type === 'selector') {
if (!~uniques.indexOf(String(child))) {
uniques.push(String(child));
} else {
child.removeSelf();
}
}
});
}
if (selector.type === 'selector' && selector.parent.type !== 'pseudo') {
if (!~uniques.indexOf(String(selector))) {
uniques.push(String(selector));
if (!~uniqueSelectors.indexOf(toString)) {
uniqueSelectors.push(toString);
} else {

@@ -88,19 +97,10 @@ selector.removeSelf();

}
});
selectors.eachPseudo(function (pseudo) {
uniques = [];
pseudo.eachInside(function (selector) {
if (selector.type === 'selector') {
if (!~uniques.indexOf(String(selector))) {
uniques.push(String(selector));
} else {
selector.removeSelf();
}
if (selector.type === 'tag') {
if (selector.value === 'from') { selector.value = '0%'; }
if (selector.value === '100%') { selector.value = 'to'; }
}
if (selector.type === 'universal') {
if (next && next.type !== 'combinator') {
selector.removeSelf();
}
});
});
selectors.eachUniversal(function (selector) {
var next = selector.next();
if (next && next.type !== 'combinator') {
selector.removeSelf();
}

@@ -107,0 +107,0 @@ });

{
"name": "postcss-minify-selectors",
"version": "1.4.6",
"version": "1.4.7",
"description": "Minify selectors with PostCSS.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc