-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Issue with rulesets and scope #2156
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
Comments
Basically most of it is because of #2064 (It's sort of bug but we agreed to consider it as a "known limitation" for the moment, see also less/less-docs#201). I.e. "Detached rulesets simply do not expose their variables into caller scope".
which in its turn seems like another issue (I suppose it's somewhat close to #1316 but may be not the same. Though I usually redirect all "global scope overrides parent/caller/callee scope" issues to #1316). |
A workaround for your case could be something like this (or some similar variation depending on your needs). |
Allright, in that case I'll make sure to use unnamed namespaces to keep things predictable. Considering this is a "known limitation", can I expect to be relatively safe when using this workaround? Or would a potential future update to overcome the known limitation end up breaking the namespaced workaround? |
With "known limitation" I refer to "Detached rulesets simply do not expose their variables into caller scope". The unnamed namespace trick is unrelated and I expect it to work in future just fine (unless we'll break the whole idea of |
Awesome :D Thanx for the help! |
@seven-phases-max Do you know if this is this related to what I just posted: #2212? |
I ran into what seems to be a bug with scoping and passing around detached rulesets. I've tried to narrow the problem down to it's essentials. Lets say we start off with setting and calculating a few variables:
Now I'd like to generate some mobile styles and alter them for use on desktop computers:
This less code compiles to the following:
As you can see, the padding on the button has not changed for desktop styles, despite explicitly passing the desktop variables into the
.button-vars()
mixin.However, if I change my less code such that the original mobile styles are scoped within a media query, everything works as expected:
Compiles to:
Same goes for using an empty parent selector:
Compiles to:
I'm experiening these errors using:
lessc 1.7.4 (Less Compiler) [JavaScript]
The text was updated successfully, but these errors were encountered: