Re: [csswg-drafts] [css-mixins-1] Alternatives to using a scoping rule (#13727)

> The `div` gets a 100px width regardless. Under your proposal, the `figure` would *also* get a 100px width, as it can inherit the value from its parent `div` and its `font-size` doesn't matter. But the `p` would get a `200px` width, as it can't inherit so it falls back to resolving the `10em` against itself. That's pretty confusing! 

Fair. But that's only because of how we've defined arguments to work. What if `& > figure` could get `--arg` as a token stream, same as an unregistered property, and resolve it locally?

One way to do this could be to do the hygienic rewriting *twice* for arguments with a type, one with an unregistered custom property and one with a registered one, i.e if your `--arg` gets rewritten to `--arg-c5f2d35` and `--arg-c5f2d35-length`, your mixin could produce this rule:

```css
&, & > figure, & + p {
 --arg-c5f2d35: inherit(--arg-c5f2d35, 10em); /* unregistered, so it doesn't become 100px */
 --arg-c5f2d35-length: var(--arg-c5f2d35); /* 100px for div, 200px for > figure, 300px for & + p! */
 width: var(--arg-c5f2d35-length);
}
```

I'll need to think more about how this should behave with new local vars defined outside `@result`, but it seems like something with these broad strokes _could_ perhaps work?

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


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

Received on Wednesday, 25 March 2026 19:21:29 UTC