Skip to content

Commit

Permalink
Don't include .prose in :where pseudos
Browse files Browse the repository at this point in the history
Fixes #351
  • Loading branch information
adamwathan committed Apr 24, 2024
1 parent cacc7dc commit 1626076
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ const computed = {

function inWhere(selector, { className, modifier, prefix }) {
let prefixedNot = prefix(`.not-${className}`).slice(1)
let selectorPrefix = selector.startsWith('>')
? `${modifier === 'DEFAULT' ? `.${className}` : `.${className}-${modifier}`} `
: ''
let combinator = ''

// Make sure leading '>' is pulled out of the `:where` pseudo we generate, because it's invalid in that context
if (selector.startsWith('>')) {
selector = selector.slice(1)
combinator = '>'
}

// Parse the selector, if every component ends in the same pseudo element(s) then move it to the end
let [trailingPseudo, rebuiltSelector] = commonTrailingPseudos(selector)

if (trailingPseudo) {
return `:where(${selectorPrefix}${rebuiltSelector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))${trailingPseudo}`
return `${combinator}:where(${rebuiltSelector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))${trailingPseudo}`
}

return `:where(${selectorPrefix}${selector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))`
return `${combinator}:where(${selector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))`
}

function isObject(value) {
Expand Down

0 comments on commit 1626076

Please sign in to comment.