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

BUG: Can't override variables with 'when' statement #2634

Closed
janannedh opened this issue Jul 13, 2015 · 2 comments
Closed

BUG: Can't override variables with 'when' statement #2634

janannedh opened this issue Jul 13, 2015 · 2 comments

Comments

@janannedh
Copy link

It's not possible to override @variables with a 'when' statement, like this for example :

@a: false;
@b: 1px;

& when (@a = false) {
    @b: 2px;
}

But it is possible it like this:
```less
@a: false;
@b: 1px;

& when (@a = false) {
    #c {
        width: 2px;
    };
}

I tried all kinds of solutions:
http://stackoverflow.com/questions/31378687/less-when-statement-without-classname

Is this a bug?

@seven-phases-max
Copy link
Member

please use backticks to format you code.

No, not a bug.

& {...} statement is an ordinal ruleset (just like div {...} for example), and as an ordinal ruleset it should not expose its content (variables and mixins) to an outer scope (see #2072 for more details).
There're other ways to achieve conditional variable definition, but to suggest something specific we need you to provide a bit more specific example of your use-case.

P.S. I see you've already asked a more specific question at http://stackoverflow.com/questions/31378687 and I guess there're already a few answers to fit.

@seven-phases-max
Copy link
Member

Closing as expected behaviour (and duplicate of #2072 if it's about to be turned into feature request).

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

No branches or pull requests

2 participants