postcss-unique-selectors 8.0.3 → 8.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +7 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-unique-selectors",
3
- "version": "8.0.3",
3
+ "version": "8.0.4",
4
4
  "description": "Ensure CSS selectors are unique.",
5
5
  "exports": {
6
6
  ".": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "cssnano/cssnano"
34
+ "url": "git+https://github.com/cssnano/cssnano.git"
35
35
  },
36
36
  "dependencies": {
37
37
  "postcss-selector-parser": "^7.1.5"
package/src/index.js CHANGED
@@ -15,19 +15,6 @@ function generateUniqueSelector(selectors) {
15
15
  // Without comments the node's own toString is already a usable key.
16
16
  const hasComments = selectors.includes('/*');
17
17
 
18
- /**
19
- *
20
- * @param {string[]} param0
21
- * @param {string[]} param1
22
- * @returns {number}
23
- */
24
- function sortSelectors([a], [b]) {
25
- if (a > b) {
26
- return 1;
27
- } else {
28
- return a < b ? -1 : 0;
29
- }
30
- }
31
18
  /** @type {selectorParser.SyncProcessor<void>} */
32
19
  const collectUniqueSelectors = (selNode) => {
33
20
  for (const node of selNode.nodes) {
@@ -65,7 +52,13 @@ function generateUniqueSelector(selectors) {
65
52
  selectorParser(collectUniqueSelectors).processSync(selectors);
66
53
 
67
54
  return [...uniqueSelectors.entries()]
68
- .sort(sortSelectors)
55
+ .toSorted(([a], [b]) => {
56
+ if (a > b) {
57
+ return 1;
58
+ } else {
59
+ return a < b ? -1 : 0;
60
+ }
61
+ })
69
62
  .map(([, selector]) => selector)
70
63
  .join();
71
64
  }