Re: [csswg-drafts] Declarative custom functions (#7490)

> Do we need initial argument values for when the function is referenced with too few arguments?

As you note, just ensuring that unpassed arguments produce invalid variables suffices, since you can use variable fallback to supply the default value then. It might still be *useful* to have a default value expressed more declaratively, purely as an authoring convenience.

> Is there a need for a result syntax and a fallback value?

No, a result syntax isn't needed. Custom *properties* need a syntax to enable animation of the *properties*, but you don't need to do anything special to enable animation of a value with a `var()` in it, and this is equivalent to a `var()`.

A fallback used when the passed arguments don't match their declared syntaxes makes sense! And if no fallback is specified, it just operates normally with those arguments resolved to the invalid value, so you can handle them with fallback if desired.

> Would a single space be allowed as an argument, similar to a space in a custom property declaration?

Note that the distinction between `--foo:;` and `--foo: ;` was an accident of a clumsily written property grammar. The current spec correctly doesn't distinguish between them. So both of your examples should have identical behavior. (And in either case, the value wouldn't match the syntax unless it was `"*"` or ended with a `?`.)

> Would the initial value of result be the guaranteed-invalid value?

It would be a required declaration, so there wouldn't be an initial value. (And declarations don't accept the CSS-wide keywords unless they're specified to.)

You can still make a function that's guaranteed to be invalid in various ways; for example, writing an invalid `var()` function.

> Is there anything stopping us from declaring the syntax inline with the arguments?

Nope, and that's indeed probably better.

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


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

Received on Friday, 23 September 2022 20:48:03 UTC