Skip to content

Commit 17f1d13

Browse files
committed
re-add logic for special types (class, id, attribute)
1 parent 0dbbeb0 commit 17f1d13

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/lib/resolveDefaultsAtRules.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,31 @@ function minimumImpactSelector(nodes) {
1717
return true
1818
})
1919

20-
return [nodes[0], ...rest].join('').trim()
20+
let [bestNode] = nodes
21+
22+
for (let [type, getNode = (n) => n] of [
23+
['class'],
24+
[
25+
'id',
26+
(n) =>
27+
selectorParser.attribute({
28+
attribute: 'id',
29+
operator: '=',
30+
value: n.value,
31+
quoteMark: '"',
32+
}),
33+
],
34+
['attribute'],
35+
]) {
36+
let match = nodes.find((n) => n.type === type)
37+
38+
if (match) {
39+
bestNode = getNode(match)
40+
break
41+
}
42+
}
43+
44+
return [bestNode, ...rest].join('').trim()
2145
}
2246

2347
let elementSelectorParser = selectorParser((selectors) => {

0 commit comments

Comments
 (0)