Re: [csswg-drafts] [css-mixins-1] Allow typed custom properties inside custom functions (#12317)

Hm, I see the argument for that. There's behavior you can get from inherited variables that you can't get from local variables, which isn't great. Most of the machinery of the registration isn't really necessary, tho - you honestly only need the syntax, right? Maybe we can just have a more limited syntax allowed in the function.

I keep looking for excuses to revive the `using()` prelude for some reason, lol, but having another "argument list" that just sets up some types for names you'll use in the body makes a lot of sense, I think. That is:

```css
@function --foo() using(--x <color>) returns <color> {
  --x: rgb(255 0 0);
  
  result: if(
    style(--x: red): green;
    else: black;
  );
}
```

That would just affect the set of registrations visible while evaluating the body. I don't think we *need* to allow a "default value" in the `using()`, and honestly that would probably be a bit confusing - I think it would need to be an overriding initial value, instead, which means it would be different from the value in the arguments. Probably better just to disallow, and only let you specify the type; you can supply the "initial value" at the top of the body, like in the example above.

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


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

Received on Tuesday, 15 July 2025 21:05:52 UTC