Skip to content

Commit 715dc6c

Browse files
authored
fix: vendor-prefixed selector false positives (#373)
Re-fixes #348
1 parent 43bf157 commit 715dc6c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/__fixtures__/gazelle-20231008.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87449,8 +87449,8 @@
8744987449
"uniquenessRatio": 0.09259259259259259
8745087450
},
8745187451
"prefixed": {
87452-
"total": 30,
87453-
"totalUnique": 29,
87452+
"total": 29,
87453+
"totalUnique": 28,
8745487454
"unique": {
8745587455
"button::-moz-focus-inner": 2,
8745687456
"input::-moz-focus-inner": 1,
@@ -87479,11 +87479,10 @@
8747987479
"::-webkit-search-decoration": 1,
8748087480
"::-webkit-file-upload-button": 1,
8748187481
"input::-moz-placeholder": 1,
87482-
"textarea::-moz-placeholder": 1,
87483-
".-tw-bottom-\\[35px\\]": 1
87482+
"textarea::-moz-placeholder": 1
8748487483
},
87485-
"uniquenessRatio": 0.9666666666666667,
87486-
"ratio": 0.0028161081385525205
87484+
"uniquenessRatio": 0.9655172413793104,
87485+
"ratio": 0.0027222378672674364
8748787486
},
8748887487
"combinators": {
8748987488
"total": 12605,

src/selectors/complexity.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ Complexity('calculates complexity with vendor prefixes', () => {
5858
no-prefix,
5959
fake-webkit,
6060
.-mt-px,
61-
.-space-x-1 {}
61+
.-space-x-1,
62+
.-pd-translate-y-2,
63+
.-pd-translate-x-full {}
6264
`).selectors.complexity
6365

6466
assert.equal(actual.unique, {
65-
'1': 4,
67+
'1': 6,
6668
'5': 1,
6769
'2': 1,
6870
'12': 1,

src/selectors/utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { startsWith, strEquals } from '../string-utils.js'
33
import { hasVendorPrefix } from '../vendor-prefix.js'
44
import {
55
PseudoClassSelector,
6-
IdSelector,
7-
ClassSelector,
86
PseudoElementSelector,
97
TypeSelector,
108
Combinator,
@@ -82,9 +80,7 @@ export function isPrefixed(selector) {
8280
let isPrefixed = false
8381

8482
walk(selector, function (node) {
85-
if (node.type === IdSelector
86-
|| node.type === ClassSelector
87-
|| node.type === PseudoElementSelector
83+
if (node.type === PseudoElementSelector
8884
|| node.type === TypeSelector
8985
|| node.type === PseudoClassSelector
9086
) {

0 commit comments

Comments
 (0)