🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

postcss-unique-selectors

Package Overview
Dependencies
Maintainers
8
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-unique-selectors - npm Package Compare versions

Comparing version
8.0.0
to
8.0.1
+4
-4
package.json
{
"name": "postcss-unique-selectors",
"version": "8.0.0",
"version": "8.0.1",
"description": "Ensure CSS selectors are unique.",

@@ -26,3 +26,3 @@ "main": "src/index.js",

"dependencies": {
"postcss-selector-parser": "^7.1.1"
"postcss-selector-parser": "^7.1.2"
},

@@ -36,7 +36,7 @@ "bugs": {

"devDependencies": {
"postcss": "^8.5.14"
"postcss": "^8.5.15"
},
"peerDependencies": {
"postcss": "^8.5.14"
"postcss": "^8.5.15"
}
}

@@ -9,4 +9,10 @@ 'use strict';

function generateUniqueSelector(selectors) {
// No comma means a single selector; nothing to dedupe or sort.
if (selectors.indexOf(',') === -1) {
return selectors;
}
/** @type {Map<string, string>} */
const uniqueSelectors = new Map();
// Without comments the node's own toString is already a usable key.
const hasComments = selectors.indexOf('/*') !== -1;

@@ -16,5 +22,13 @@ /** @type {selectorParser.SyncProcessor<void>} */

for (const node of selNode.nodes) {
if (!hasComments) {
const text = node.toString();
const key = text.trim();
if (!uniqueSelectors.has(key)) {
uniqueSelectors.set(key, text);
}
continue;
}
/** @type {string[]} */
const comments = [];
// Duplicates are removed by stripping the comments and using the results as the Map key.

@@ -21,0 +35,0 @@ const keyNode = node.clone();

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

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AA4CA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAiBnC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AA0DA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAiBnC"}