[csswg-drafts] [css-syntax-3] Should `<declaration-value>` embed semantics? (#11296)

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

== [css-syntax-3] Should `<declaration-value>` embed semantics? ==
This is a similar question than for #8795.

[`<declaration-value>`](https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value) represents any value that can be reasonably considered to look like a valid *standard* property. It excludes an omitted value for a *custom* property or `@property/initial-value`.

So now that [consume a declaration](https://drafts.csswg.org/css-syntax-3/#consume-declaration) (a **syntax** algorithm) should return nothing for a positioned `{}`-block, should `<declaration-value>` exclude that too? No, because a positioned `{}`-block is valid in a custom property value.

In my opinion, `<declaration-value>` (and `<any-value>`) should match *zero* or more tokens excluding `<}-token>`, `<semicolon-token>`, `<delim-token>` with a value of `!`.

From an author's perspective, it can be confusing that `background-image: var(--url, url(bad token))` is valid but not `background-image: var(--url, invalid)`, similarly as with `--left: rgb(` and `--right: 0, 0, 0)`. Ok, using custom properties outside of CSS is not their primary use. But none of these declarations looks invalid.

Now it is probably too late to allow bad tokens, `<)-token>`, `<]-token>`, but maybe not zero token.

Most of the time, `<declaration-value>` (and `<any-value>`) is explicitly made optional `?`. In [`env()`](https://drafts.csswg.org/css-env-1/#funcdef-env), [`if()`](https://drafts.csswg.org/css-values-5/#typedef-if), [`inherit()`](https://drafts.csswg.org/css-values-5/#funcdef-inherit), `random-item()`, `var()`, `@property/initial-value`, custom properties, etc.

It is not optional as a [custom function argument](https://drafts.csswg.org/css-mixins-1/#typedef-dashed-function) but `--mixin(255,, 0)` might be useful with `@function --mixin(--r: 0, r: 127, b: 0) { ... }`. It is also not optional for `@function` parameters, `param()`, `first-valid()`, but I do not want to argue why it could also be optional and make this comment longer than it already is.

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


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

Received on Friday, 29 November 2024 14:24:08 UTC