Skip to content

[css-mixins-1] Allow typed custom properties inside custom functions #12317

Open
@romainmenke

Description

@romainmenke

See: #12315

I also found it a bit surprising that there is no way to have local typed custom properties. (except result)

@property --x {
  syntax: "<color>";
  inherits: true;
  initial-value: pink;
}

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

* {
  background-color: --foo(); /* black */
}

What was the original motivation to make everything untyped inside custom functions?

Because values are resolved in imaginary child elements nothing leaks out when a function is evaluated.
I can imagine that when the types are preserved it is possible to break custom functions by registering seemingly unrelated properties.

So maybe it should be possible to do local registrations?

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