|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
774 bytes
|
| Line | |
|---|
| 1 | import parser from 'postcss-selector-parser'
|
|---|
| 2 | import { movePseudos } from './pseudoElements'
|
|---|
| 3 |
|
|---|
| 4 | export function applyImportantSelector(selector, important) {
|
|---|
| 5 | let sel = parser().astSync(selector)
|
|---|
| 6 |
|
|---|
| 7 | sel.each((sel) => {
|
|---|
| 8 | // For nesting, we only need to wrap a selector with :is() if it has a top-level combinator,
|
|---|
| 9 | // e.g. `.dark .text-white`, to be independent of DOM order. Any other selector, including
|
|---|
| 10 | // combinators inside of pseudos like `:where()`, are ok to nest.
|
|---|
| 11 | let shouldWrap = sel.nodes.some((node) => node.type === 'combinator')
|
|---|
| 12 |
|
|---|
| 13 | if (shouldWrap) {
|
|---|
| 14 | sel.nodes = [
|
|---|
| 15 | parser.pseudo({
|
|---|
| 16 | value: ':is',
|
|---|
| 17 | nodes: [sel.clone()],
|
|---|
| 18 | }),
|
|---|
| 19 | ]
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | movePseudos(sel)
|
|---|
| 23 | })
|
|---|
| 24 |
|
|---|
| 25 | return `${important} ${sel.toString()}`
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.