Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ const selectorProcessor = selectorParser(selectors => {
if (
selector.type === 'pseudo' &&
selector.toString() === ':hover' &&
selector.parent.value !== ':not' &&
selector.parent.toString() !== ':hover'
) {
let parent = selector.parent
while (parent !== undefined) {
if (parent.value === ':has' || parent.value === ':not') {
return
}

parent = parent.parent
}
hoverSelectors.push(selector.parent.toString())
}
})
Expand Down
14 changes: 14 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ describe('basic usage', () => {
'.list__item:not(:hover, .is-editing) .show-on-hover { visibility: hidden }'
)
})

it('ignores nested :hover pseudo-class selectors within :not pseudo-class selector lists', () => {
run(
'.list__item:not(.some-selector:hover) .show-on-hover { visibility: hidden }',
'.list__item:not(.some-selector:hover) .show-on-hover { visibility: hidden }'
)
})

it('ignores :hover pseudo-class selectors within :has pseudo-class selector lists', () => {
run(
'.list__item:has(.some-selector:hover) .show-on-hover { visibility: hidden }',
'.list__item:has(.some-selector:hover) .show-on-hover { visibility: hidden }'
)
})
})

describe('when `fallback: true`', () => {
Expand Down