Question about parsing with comments in selectors
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- frontend
Direzione di ricerca
Start by running the example from the issue with postcss-js and inspect the resulting rule.selector and rule.selectors values. Compare that behavior with postcss-selector-parser's handling of comments and selector updates. Done means determining whether the reported comment form is supported and, if so, preserving the comment without splitting comma-containing comments into selector entries.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Problem
First off I know this is a bit odd but, when parsing a selector with a comment before it PostCSS will treat it as a comment node. These can show up in IDEs (like VSCode for example) with information about the class. When using postcss-js the only way to do this, that I know of, is to add a comment to the selector itself. This seems to work okay-ish as long as the comment does not contain commas. If it does, any code relying on rule.selectors can break because it recieves pieces of a comment along with the other pieces of the selector.
Example Code
So, given the following:
import postcssJs from "postcss-js"
import postcss from "postcss"
const result = postcss().process({
'/* this, is, a, test */ .test': {
'color': 'blue'
}
}, {
parser: postcssJs,
}).sync()
console.log({
selector: result.root.nodes[0].selector,
selectors: result.root.nodes[0].selectors
})
You'll see that selector turns out to be: /* this, is, a, test */ .test instead of having a comment node before the rule.
The main problem though is that rule.selectors becomes an array with 4 items:
/* thisisatest */ .test
My Question
Is this something postcss-js is just not intended to support? If not, is there another possible solution? I noticed that postcss-selector-parser seems to handle comments in selectors fine — at least on some level. Though it doesn't clean out the selector of a rule when using updateSelector. I'd be happy to prep a PR that uses the selector parser to clean them but I have a feeling this might be a bit complicated because comments can technically appear in between parts of a selector which would require updating raws.
- Lingua principale
- JavaScript
- Stelle
- 667
- Fork
- 24
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di postcss/postcss-js
-
.sync APIAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 48/100
postcss/postcss-js#72 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
postcss/postcss-js#69 · 7 commenti ·
Tutte le issue di postcss/postcss-js
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
keyxmakerx/Chronicle#967 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue hacktoberfest
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
RogueAlg0/taken#386 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
LearningCircuit/local-deep-research#7067 ·
I maintainer di solito rispondono entro 1 giorno