Skip to content

[css-properties-values-api] Make all the descriptors optional #994

Open
@kizu

Description

@kizu

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions