Skip to content

Commit

Permalink
fix: vendor-prefixed selector false positives (#373)
Browse files Browse the repository at this point in the history
Re-fixes #348
  • Loading branch information
bartveneman authored Dec 30, 2023
1 parent 43bf157 commit 715dc6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
11 changes: 5 additions & 6 deletions src/__fixtures__/gazelle-20231008.json
Original file line number Diff line number Diff line change
Expand Up @@ -87449,8 +87449,8 @@
"uniquenessRatio": 0.09259259259259259
},
"prefixed": {
"total": 30,
"totalUnique": 29,
"total": 29,
"totalUnique": 28,
"unique": {
"button::-moz-focus-inner": 2,
"input::-moz-focus-inner": 1,
Expand Down Expand Up @@ -87479,11 +87479,10 @@
"::-webkit-search-decoration": 1,
"::-webkit-file-upload-button": 1,
"input::-moz-placeholder": 1,
"textarea::-moz-placeholder": 1,
".-tw-bottom-\\[35px\\]": 1
"textarea::-moz-placeholder": 1
},
"uniquenessRatio": 0.9666666666666667,
"ratio": 0.0028161081385525205
"uniquenessRatio": 0.9655172413793104,
"ratio": 0.0027222378672674364
},
"combinators": {
"total": 12605,
Expand Down
6 changes: 4 additions & 2 deletions src/selectors/complexity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ Complexity('calculates complexity with vendor prefixes', () => {
no-prefix,
fake-webkit,
.-mt-px,
.-space-x-1 {}
.-space-x-1,
.-pd-translate-y-2,
.-pd-translate-x-full {}
`).selectors.complexity

assert.equal(actual.unique, {
'1': 4,
'1': 6,
'5': 1,
'2': 1,
'12': 1,
Expand Down
6 changes: 1 addition & 5 deletions src/selectors/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { startsWith, strEquals } from '../string-utils.js'
import { hasVendorPrefix } from '../vendor-prefix.js'
import {
PseudoClassSelector,
IdSelector,
ClassSelector,
PseudoElementSelector,
TypeSelector,
Combinator,
Expand Down Expand Up @@ -82,9 +80,7 @@ export function isPrefixed(selector) {
let isPrefixed = false

walk(selector, function (node) {
if (node.type === IdSelector
|| node.type === ClassSelector
|| node.type === PseudoElementSelector
if (node.type === PseudoElementSelector
|| node.type === TypeSelector
|| node.type === PseudoClassSelector
) {
Expand Down

0 comments on commit 715dc6c

Please sign in to comment.