[csswg-drafts] [css-conditional-3] `CSS.supports(--custom, value)` should not accept any value (#8823)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-conditional-3] `CSS.supports(--custom, value)` should not accept any value ==
`CSS.supports('--custom', ';')` returns `false` in Chrome/FF but:

  > When the `supports(property, value)` method is invoked with two arguments `property` and `value`:
  >
  > 1. If `property` is an ASCII case-insensitive match for any defined CSS property that the UA supports, and `value` successfully [parses](https://w3c.github.io/csswg-drafts/css-syntax-3/#css-parse-something-according-to-a-css-grammar) according to that property’s grammar, return `true`.
  > 2. **Otherwise, if `property` is a custom property name string, return `true`.**

[CSS Conditional 3](https://w3c.github.io/csswg-drafts/css-conditional-3/#dom-css-supports)

They are certainly right: `;` does not successfully parse according to [the grammar of a custom property](https://w3c.github.io/csswg-drafts/css-variables-2/#propdef-). I would suggest:

  > 2. Otherwise, if `property` is a custom property name string, and `value` successfully [parses](https://w3c.github.io/csswg-drafts/css-syntax-3/#css-parse-something-according-to-a-css-grammar) against [the grammar of a custom property](https://w3c.github.io/csswg-drafts/css-variables-2/#propdef-), return `true`.

However I am also unconfortable with *"successfully parses according to that property’s grammar"* because `CSS.supports('color', 'var(--custom)')` returns `true` but `var(--custom)` is not really part of `color`'s grammar.

I think the most appropriate procedure lives in [*parse a CSS declaration block*](https://w3c.github.io/csswg-drafts/cssom-1/#parse-a-css-declaration-block), which is used to parse `CSSStyleDeclaration.cssText`, and which should be used in [*parse a CSS [property] value*](https://w3c.github.io/csswg-drafts/cssom-1/#parse-a-css-value), which is used to parse `CSSStyleDeclaration.setProperty(property, value)`:

  > [...] Let `parsed declaration` be the result of parsing declaration according to the appropriate CSS specifications, dropping parts that are said to be ignored. [...]

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 9 May 2023 08:08:08 UTC