persona-community-5/.pnpm-store/v3/files/6b/fc0aa12254473bdbaaf8239666d6c71f6f904c73c7aa0c94f93f45f5eb04a79ab9429ed4474c6d5770564e418ea5706d475515d2595985cb48674f7a6dc45e
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

27 lines
774 B
Plaintext

import parser from 'postcss-selector-parser'
import { movePseudos } from './pseudoElements'
export function applyImportantSelector(selector, important) {
let sel = parser().astSync(selector)
sel.each((sel) => {
// For nesting, we only need to wrap a selector with :is() if it has a top-level combinator,
// e.g. `.dark .text-white`, to be independent of DOM order. Any other selector, including
// combinators inside of pseudos like `:where()`, are ok to nest.
let shouldWrap = sel.nodes.some((node) => node.type === 'combinator')
if (shouldWrap) {
sel.nodes = [
parser.pseudo({
value: ':is',
nodes: [sel.clone()],
}),
]
}
movePseudos(sel)
})
return `${important} ${sel.toString()}`
}