w3c/css-houdini-drafts

[css-properties-values-api] Rationale for `registerProperty()` taking precedence over `@property`?

Closed this issue · 1 comments

alice commented

Coming here from w3ctag/design-reviews#402 (thanks @andruud for the helpful links to controversial closed issues!)

In #845, @tabatkins wrote

registerProperty() wins over @Property rules

I'm curious what the rationale is, since it doesn't seem to be documented in that issue.

[Edit: deleted a point which is captured in #942]

The rationale is that JS is generally more explicit of a signal than CSS, and this is more or less reflected in other CSS APIs, such as .style winning over stylesheet declarations by default.

Also, if you're using JS already, using the JS API is far easier than manipulating the OM of a stylesheet, if you want to add a declaration without regards to what's already defined. You might not even be able to find the last @Property instance, because it might be in a cross-origin stylesheet (which doesn't expose its contents). So since JS has to be either behind all CSS, or in front of all CSS, putting it in front just seems more convenient.

(Closing because question is answered; feel free to continue discussion if necessary.)