Re: [css-houdini-drafts] [css-properties-values-api] Syntax-checking in CSSStyleDeclaration.setProperty

The behavior is inconsistent, but intentional.

Registered custom properties don't reject invalid values at parse time *from a style sheet*, so that browsers don't have to reparse all the styles on the page to determine the correct cascade (or, equivalently, preserve the entire list of cascaded values for every custom property); instead, you just decide at computed-value time whether the value that won the cascade is valid or not.

But there's no similar implementation difficulty for checking the validity of a style set from JS.  Throwing an error gives useful feedback to the author, even if it does mean that there's now an order-dependence in the results.

(That is, setting a property then registering it gives no error, even if the value doesn't match the grammar; it just ends up as invalid at computed-value time. But registering the property and then setting it will throw an error if it doesn't match the grammar.)

I'll amend the note to make it clearer that this is an intentional inconsistency, however.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/778#issuecomment-406440820 using your GitHub account

Received on Thursday, 19 July 2018 23:07:39 UTC