Socket
Socket
Sign inDemoInstall

postcss-minify-selectors

Package Overview
Dependencies
Maintainers
1
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.1.0 to 1.2.0

lib/replaceOutsideQuotes.js

5

CHANGELOG.md

@@ -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",

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