Socket
Socket
Sign inDemoInstall

postcss-minify-selectors

Package Overview
Dependencies
Maintainers
5
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 4.0.0-rc.2 to 4.0.0

74

dist/index.js

@@ -31,3 +31,3 @@ 'use strict';

var pseudoElements = ['::before', '::after', '::first-letter', '::first-line'];
const pseudoElements = ['::before', '::after', '::first-letter', '::first-line'];

@@ -47,5 +47,27 @@ function getParsed(selectors, callback) {

}
if (selector.raws && selector.raws.insensitive) {
selector.raws.insensitive = '';
if (!selector.raws) {
selector.raws = {};
}
if (!selector.raws.spaces) {
selector.raws.spaces = {};
}
selector.raws.spaces.attribute = {
before: '',
after: ''
};
selector.raws.spaces.operator = {
before: '',
after: ''
};
selector.raws.spaces.value = {
before: '',
after: selector.insensitive ? ' ' : ''
};
if (selector.insensitive) {
selector.raws.spaces.insensitive = {
before: '',
after: ''
};
}
selector.attribute = selector.attribute.trim();

@@ -55,7 +77,7 @@ }

function combinator(selector) {
var value = selector.value.trim();
const value = selector.value.trim();
selector.value = value.length ? value : ' ';
}
var pseudoReplacements = {
const pseudoReplacements = {
':nth-child': ':first-child',

@@ -69,4 +91,4 @@ ':nth-of-type': ':first-of-type',

if (selector.nodes.length === 1 && pseudoReplacements[selector.value]) {
var first = selector.at(0);
var one = first.at(0);
const first = selector.at(0);
const one = first.at(0);
if (first.length === 1) {

@@ -83,4 +105,4 @@ if (one.value === '1') {

if (first.length === 3) {
var two = first.at(1);
var three = first.at(2);
const two = first.at(1);
const three = first.at(2);
if (one.value === '2n' && two.value === '+' && three.value === '1') {

@@ -95,6 +117,6 @@ one.value = 'odd';

}
var uniques = [];
selector.walk(function (child) {
const uniques = [];
selector.walk(child => {
if (child.type === 'selector') {
var childStr = String(child);
const childStr = String(child);
if (!~uniques.indexOf(childStr)) {

@@ -112,3 +134,3 @@ uniques.push(childStr);

var tagReplacements = {
const tagReplacements = {
from: '0%',

@@ -119,4 +141,3 @@ '100%': 'to'

function tag(selector) {
var value = selector.value;
const { value } = selector;
if ((0, _has2.default)(tagReplacements, value)) {

@@ -128,3 +149,3 @@ selector.value = tagReplacements[value];

function universal(selector) {
var next = selector.next();
const next = selector.next();
if (next && next.type !== 'combinator') {

@@ -135,3 +156,3 @@ selector.remove();

var reducers = {
const reducers = {
attribute,

@@ -145,3 +166,3 @@ combinator,

function optimise(rule) {
var selector = rule.raws.selector && rule.raws.selector.value === rule.selector ? rule.raws.selector.raw : rule.selector;
const selector = rule.raws.selector && rule.raws.selector.value === rule.selector ? rule.raws.selector.raw : rule.selector;
// If the selector ends with a ':' it is likely a part of a custom mixin,

@@ -152,9 +173,8 @@ // so just pass through.

}
rule.selector = getParsed(selector, function (selectors) {
rule.selector = getParsed(selector, selectors => {
selectors.nodes = (0, _alphanumSort2.default)(selectors.nodes, { insensitive: true });
var uniqueSelectors = [];
selectors.walk(function (sel) {
var type = sel.type;
const uniqueSelectors = [];
selectors.walk(sel => {
const { type } = sel;
// Trim whitespace around the value
sel.spaces.before = sel.spaces.after = '';

@@ -165,3 +185,3 @@ if ((0, _has2.default)(reducers, type)) {

}
var toString = String(sel);
const toString = String(sel);
if (type === 'selector' && sel.parent.type !== 'pseudo') {

@@ -178,7 +198,5 @@ if (!~uniqueSelectors.indexOf(toString)) {

exports.default = (0, _postcss.plugin)('postcss-minify-selectors', function () {
return function (css) {
return css.walkRules(optimise);
};
exports.default = (0, _postcss.plugin)('postcss-minify-selectors', () => {
return css => css.walkRules(optimise);
});
module.exports = exports['default'];

@@ -19,4 +19,4 @@ 'use strict';

*/
var escapes = /\\([0-9A-Fa-f]{1,6})[ \t\n\f\r]?/g;
var range = /[\u0000-\u002c\u002e\u002f\u003A-\u0040\u005B-\u005E\u0060\u007B-\u009f]/;
const escapes = /\\([0-9A-Fa-f]{1,6})[ \t\n\f\r]?/g;
const range = /[\u0000-\u002c\u002e\u002f\u003A-\u0040\u005B-\u005E\u0060\u007B-\u009f]/;

@@ -23,0 +23,0 @@ function canUnquote(value) {

@@ -7,6 +7,4 @@ 'use strict';

exports.default = function (string) {
return string.replace(/["']/g, '');
};
exports.default = string => string.replace(/["']/g, '');
module.exports = exports['default'];
{
"name": "postcss-minify-selectors",
"version": "4.0.0-rc.2",
"version": "4.0.0",
"description": "Minify selectors with PostCSS.",

@@ -24,6 +24,6 @@ "main": "dist/index.js",

"babel-cli": "^6.0.0",
"cross-env": "^3.0.0",
"cross-env": "^5.0.0",
"postcss-font-magician": "^2.0.0"
},
"homepage": "https://github.com/ben-eb/cssnano",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -34,3 +34,3 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/cssnano",
"repository": "cssnano/cssnano",
"dependencies": {

@@ -40,10 +40,10 @@ "alphanum-sort": "^1.0.0",

"postcss": "^6.0.0",
"postcss-selector-parser": "^3.0.0-rc.0"
"postcss-selector-parser": "^3.0.0"
},
"bugs": {
"url": "https://github.com/ben-eb/cssnano/issues"
"url": "https://github.com/cssnano/cssnano/issues"
},
"engines": {
"node": ">=4"
"node": ">=6.9.0"
}
}

@@ -36,3 +36,3 @@ # [postcss][postcss]-minify-selectors

See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md).
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).

@@ -39,0 +39,0 @@ ## License

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