Re: [csswg-drafts] [css-mixins-1] Need a non-hacky way to force an element-dependent value on the applying element (#13454)

@tabatkins So to clarify, local hygiene would would have to combined with `--em: --as-length(...)` and `0.2--em` to get the desired effect here?

In this "most hygienic" model, the mixin body then approximately becomes an `&` rule, vending `--magic-*` properties:

```css
@mixin --enhance(--x <number>, --y <number>) {
  --derived: 0;
  @container (...) {
    --derived: calc(var(--x) + var(--y));
  }
  @result {
    --out: var(--derived);
  }
}
```

=> (pseudo-css)

```css
@mixin --enhance(--x <number>, --y <number>) {
  & { /*magic*/
    --magic-x <number>: /* argument to x */;
    --magic-y <number>: /* argument to y */;
    --magic-derived: 0;
    @container (...) {
      --magic-derived: calc(var(--x) + var(--y));
    }
  }
  @result {
    --out: var(--magic-derived);
  }
}
```

This means the `@container` effectively resolves against the `@apply`-element for _any_ `var(--magic-derived)`, regardless of which element is targeted. That could be reasonable in this mode?

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


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

Received on Wednesday, 18 February 2026 11:56:22 UTC