Socket
Socket
Sign inDemoInstall

postcss-minify-selectors

Package Overview
Dependencies
7
Maintainers
8
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.1 to 5.1.2

62

dist/index.js

@@ -8,4 +8,2 @@ "use strict";

var _alphanumSort = _interopRequireDefault(require("alphanum-sort"));
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));

@@ -17,3 +15,3 @@

const pseudoElements = ['::before', '::after', '::first-letter', '::first-line'];
const pseudoElements = new Set(['::before', '::after', '::first-letter', '::first-line']);

@@ -82,8 +80,3 @@ function attribute(selector) {

const pseudoReplacements = {
':nth-child': ':first-child',
':nth-of-type': ':first-of-type',
':nth-last-child': ':last-child',
':nth-last-of-type': ':last-of-type'
};
const pseudoReplacements = new Map([[':nth-child', ':first-child'], [':nth-of-type', ':first-of-type'], [':nth-last-child', ':last-child'], [':nth-last-of-type', ':last-of-type']]);

@@ -93,3 +86,3 @@ function pseudo(selector) {

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

@@ -101,3 +94,3 @@ const one = first.at(0);

selector.replaceWith(_postcssSelectorParser.default.pseudo({
value: pseudoReplacements[value]
value: pseudoReplacements.get(value)
}));

@@ -125,3 +118,3 @@ }

const uniques = [];
const uniques = new Set();
selector.walk(child => {

@@ -131,4 +124,4 @@ if (child.type === 'selector') {

if (!~uniques.indexOf(childStr)) {
uniques.push(childStr);
if (!uniques.has(childStr)) {
uniques.add(childStr);
} else {

@@ -140,3 +133,3 @@ child.remove();

if (~pseudoElements.indexOf(value)) {
if (pseudoElements.has(value)) {
selector.value = selector.value.slice(1);

@@ -146,6 +139,3 @@ }

const tagReplacements = {
from: '0%',
'100%': 'to'
};
const tagReplacements = new Map([['from', '0%'], ['100%', 'to']]);

@@ -155,4 +145,4 @@ function tag(selector) {

if (Object.prototype.hasOwnProperty.call(tagReplacements, value)) {
selector.value = tagReplacements[value];
if (tagReplacements.has(value)) {
selector.value = tagReplacements.get(value);
}

@@ -169,9 +159,3 @@ }

const reducers = {
attribute,
combinator,
pseudo,
tag,
universal
};
const reducers = new Map([['attribute', attribute], ['combinator', combinator], ['pseudo', pseudo], ['tag', tag], ['universal', universal]]);

@@ -185,15 +169,10 @@ function pluginCreator() {

const processor = (0, _postcssSelectorParser.default)(selectors => {
selectors.nodes = (0, _alphanumSort.default)(selectors.nodes, {
insensitive: true
});
const uniqueSelectors = [];
const uniqueSelectors = new Set();
selectors.walk(sel => {
const {
type
} = sel; // Trim whitespace around the value
// Trim whitespace around the value
sel.spaces.before = sel.spaces.after = '';
const reducer = reducers.get(sel.type);
if (Object.prototype.hasOwnProperty.call(reducers, type)) {
reducers[type](sel);
if (reducer !== undefined) {
reducer(sel);
return;

@@ -204,5 +183,5 @@ }

if (type === 'selector' && sel.parent.type !== 'pseudo') {
if (!~uniqueSelectors.indexOf(toString)) {
uniqueSelectors.push(toString);
if (sel.type === 'selector' && sel.parent.type !== 'pseudo') {
if (!uniqueSelectors.has(toString)) {
uniqueSelectors.add(toString);
} else {

@@ -213,2 +192,3 @@ sel.remove();

});
selectors.nodes.sort();
});

@@ -215,0 +195,0 @@ css.walkRules(rule => {

{
"name": "postcss-minify-selectors",
"version": "5.1.1",
"version": "5.1.2",
"description": "Minify selectors with PostCSS.",

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

"dependencies": {
"alphanum-sort": "^1.0.2",
"postcss-selector-parser": "^6.0.5"

@@ -30,0 +29,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc