[css-houdini-drafts] [css-properties-values-api] Make all the descriptors optional (#994)

kizu has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== [css-properties-values-api] Make all the descriptors optional ==
https://drafts.css-houdini.org/css-properties-values-api-1/

For convenience I would talk about the CSS syntax, but the same could apply to the `registerProperty()` JS function as well.

Currently, all the declarations inside the `@property` are required (https://drafts.css-houdini.org/css-properties-values-api-1/#at-property-rule), (with the exception of `initial-value`, but only for universal syntax definition (`*`).

My suggestion: make _all_ declarations optional, and if at least one descriptor is properly defined, the custom property should become registered.

Basically, each `descriptor` could have a “default”:

1. `syntax` should default to the universal syntax definition. This would allow to conveniently set a variable to be non-inherited without explicitly typing it or setting an initial value.

2. `inherits` should default to `true`, as this is the default for unregistered properties. There is no reason to require this descriptor to be explicitly required, and making it optional would allow to use the `@property` to more conveniently register properties that could be transitioned.

3. `initial-value` should default to… not sure how it can be described, but basically, an “invalid” value. If the syntax is properly defined, then the property should still be able to be transitioned/animated, just both states should be defined, without a transition to or from the “invalid” value.

Overall, making all these optional would make the API much easier to use and would reduce potential human errors when registering the custom properties, and would lead to a more readable code overall, as for a lot of cases the property definitions would be more concise and containing only the things developers want to explicitly set.

Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/994 using your GitHub account

Received on Thursday, 23 July 2020 22:24:44 UTC