Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-properties-values-api] Make initial-value descriptor optional #1109

Open
LeaVerou opened this issue Oct 12, 2023 · 0 comments
Open

[css-properties-values-api] Make initial-value descriptor optional #1109

LeaVerou opened this issue Oct 12, 2023 · 0 comments

Comments

@LeaVerou
Copy link
Member

Currently writing @property rules is fairly verbose and repetitive. All three descriptors are mandatory, and often forgotten, causing hard to debug bugs.

It’s unfortunate that inherits cannot be optional since the only default value that makes sense is also the slowest, but what about initial-value?

I think we can compute a sensible initial value for any syntax string except * (in which case it should be mandatory). In addition to making code shorter, it is often nontrivial to specify a suitable, computationally independent initial value (e.g. for <image>, especially before image() is implemented).

In some cases there is no obvious initial value, but that is a problem for authors as well: there should be a suitable initial value for each value type. If there isn't, it's a bug with the value type.

  • <url>. Built-in CSS properties solve this by accepting a keyword as well (e.g. none).
  • <transform-function>: what if we added none as a value? It would be compatible with existing properties, and would mean authors wouldn't need to keep doing <transform-function> | none
  • <transform-list>, see above

The other elementary types are pretty straight forward:

  • 0 for <number> and <integer>
  • 0{unit} for any dimension type (<length>, <angle>, <percentage>, <length-percentage> etc)
  • transparent for <color>
  • image(transparent) for <image>
  • keyword → itself

For more complex syntax constructs, a suitable initial value can be generated recursively:

  • A | BA
  • A+A
  • A# → A

cc @tabatkins

@nt1m nt1m transferred this issue from w3c/csswg-drafts Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant