Skip to content

[css-mixins-1] Lexical vs. dynamic env() scoping #12677

@andruud

Description

@andruud

If I understand the current spec correctly, you can not access outer mixin parameters from an inner @apply "call", since the target of that @apply call won't have the necessary lexical scope in its parent rule chain:

@mixin --one() {
  & { color: env(--color); } /* --color not defined here */
}

@mixin --two() {
  @env --color: green;
  @apply --one();
}

div { @apply --two(); }

I'm not a huge fan of dynamic scoping personally, and I do get that that authors can just define their envs at the stylesheet-level if they want "globals", but this feels inconsistent with what we decided in #10954, so I'd like an explicit decision on this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions