Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value is not calculated for css --variables #3800

Closed
Dagur opened this issue Jun 14, 2023 · 2 comments
Closed

Value is not calculated for css --variables #3800

Dagur opened this issue Jun 14, 2023 · 2 comments
Labels

Comments

@Dagur
Copy link

Dagur commented Jun 14, 2023

To reproduce:

.test {
  width: 20px + 40px;  
  --width: 20px + 40px;  
}

Current behavior:

output is

.test {
  width: 60px;
  --width: 20px + 40px;
}

Expected behavior:

I expected

.test {
  width: 60px;
  --width: 60px;
}

Environment information:

This can cause unexpected problems when combined with less @variables.

@Dagur Dagur added the bug label Jun 14, 2023
@matthew-dean
Copy link
Member

This is by design and not a bug. For example, let's say you had this:

.test {
  --width: 20px + foo({ 40: 'px' });
}

What should Less do with this? The value you have for --width is 100% perfectly valid, and you could be intending to evaluate it as JavaScript, so it couldn't throw an error as an invalid expression. Instead, you have to evaluate it before-hand:

.test {
  @width: 20px + 40px;
  --width: @width;
}

Less evaluating at-rules in custom properties has its own add-in side-effects / bugs, but that's what is currently supported.

@Dagur
Copy link
Author

Dagur commented Jun 14, 2023

Maybe this bug should be about lack of documentation then? I tried to look this up and found nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants