Making the CSS property `appliesto` values more specific

Abierto
#585 9 comentarios 5 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@teoli2003 ya está trabajando en esto.

Desde el 8/6/2022.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
css
Área
web-dev

Línea de trabajo

Comienza revisando el enum appliesto en css/properties.schema.json y las entradas relacionadas en css/properties.json, usando align-items, grid-auto-columns y align-content como casos de comparación. Revisa los datos de inactive-css enlazados y determina si el enum existente puede expresar la especificidad solicitada. Se considera terminado cuando se haya llegado a un acuerdo sobre el alcance y la representación antes de actualizar los datos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

idle

It feels to me like the appliesto property of the CSS properties data isn't defined very specifically at the moment.

For context, here is a concrete example:
https://developer.mozilla.org/en-US/docs/Web/CSS/align-items#formal_definition

MDN says that align-items applies to all elements (data is here). While true in the sense that it won't break if you apply it to any element, it actually won't do anything unless the element is not a grid container or a flex container.

Contrast this with this other example:
https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns#formal_definition

MDN says that grid-auto-columns only applies to grid containers, which is true. But also, it won't cause any problem if you apply it to any other type of containers.

I would love if appliesto was more specific. There seems to be a lot of different values that the appliesto enum can take: https://github.com/mdn/data/blob/main/css/properties.schema.json#L162
and using the most specific one has advantages: it makes it easier for web authors to know why a property they're using isn't doing anything.

As an example, if you're confused about flexbox and you're trying to align items using align-content but you did not specify flex-wrap:wrap, then the property won't have any effects.

In this specific case, the data is actually very helpful. MDN says that align-content only applies to multi-line flex containers: https://developer.mozilla.org/en-US/docs/Web/CSS/align-content#formal_definition
Although it's not entirely correct because it also applies to grid containers.

So I have two questions in this issue:

  1. Does everyone agree that the appliesto property should be as specific as possible for all properties?
  2. Is there interest in expanding the appliesto enum to make it able to cover more cases? For example, there is no gridAndFlexContainer value now, but it would be useful in the align-content case. In fact, it might become useful, at some point, to allow more complex values than just strings. For instance: gridContainer AND flexContainer seems like it would help.

As background to this, in the past I worked on this inactive-css repo with the hope to create a reusable dataset for exactly this case: https://github.com/captainbrosset/inactive-css
I'd be willing to transfer this data over to mdn/data (by mapping it to the appliesto field) if there is interest.

Lenguaje dominante
JavaScript
Estrellas
786
Forks
216
Merge medio
22 h 24 min
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de mdn/data

Todos los issues de mdn/data

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.