postcss-minify-selectors
Advanced tools
Comparing version
{ | ||
"name": "postcss-minify-selectors", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "Minify selectors with PostCSS.", | ||
@@ -42,4 +42,3 @@ "main": "src/index.js", | ||
"postcss": "^8.2.15" | ||
}, | ||
"readme": "# [postcss][postcss]-minify-selectors\n\n> Minify selectors with PostCSS.\n\n## Install\n\nWith [npm](https://www.npmjs.com/package/postcss-minify-selectors) do:\n\n```\nnpm install postcss-minify-selectors --save\n```\n\n## Example\n\n### Input\n\n```css\nh1 + p, h2, h3, h2{color:blue}\n```\n\n### Output\n\n```css\nh1+p,h2,h3{color:blue}\n```\n\nFor more examples see the [tests](test.js).\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n" | ||
} | ||
} |
@@ -134,13 +134,14 @@ 'use strict'; | ||
const uniques = new Set(); | ||
selector.walk((child) => { | ||
if (child.type === 'selector') { | ||
const childStr = String(child); | ||
if (child.type === 'selector' && child.parent) { | ||
const uniques = new Set(); | ||
child.parent.each((sibling) => { | ||
const siblingStr = String(sibling); | ||
if (!uniques.has(childStr)) { | ||
uniques.add(childStr); | ||
} else { | ||
child.remove(); | ||
} | ||
if (!uniques.has(siblingStr)) { | ||
uniques.add(siblingStr); | ||
} else { | ||
sibling.remove(); | ||
} | ||
}); | ||
} | ||
@@ -147,0 +148,0 @@ }); |
252
0.8%9510
-6.48%