Question about parsing with comments in selectors
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- frontend
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 667
- Forks
- 24
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de postcss/postcss-js
-
.sync APIAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 48/100
postcss/postcss-js#72 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
postcss/postcss-js#69 · 7 comentarios ·
Todos los issues de postcss/postcss-js
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
smansfield635-create/smansfield635-create.github.io#5818 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
danjdewhurst/story-skills#538 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
anoopcodehack/DevBoard#589 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 85/100
capricorn86/happy-dom#2474 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
vigetlabs/mega-menu-block#30 ·
Los mantenedores suelen responder en 2 días