Open twhoff opened 8 years ago
Note to self: The issue is caused by these lines: https://github.com/SomMeri/less4j/blob/bca5cb262c018f38ea8c58175df344c7d2345148/src/main/java/com/github/sommeri/less4j/core/compiler/stages/MixinsRulesetsSolver.java#L139-L144
The toIndependentWorkingCopy
ensures that second call does not see imported variables. Solution: the joinIfIndependent
method needs to work differently for local calls.
Scope inheritance in LESS4J is not working as intended in LESS.
Basically, child mixins inherit global scope OR parent scope before any operations on variables take place.
Simple example
In the following code
@width
is inherited from the global scope in.fluid-col()
.The
.calculate()
mixin then converts the number to a valid percentage, and as@width
is not explicitly set within the scope of.fluid-col()
, the unlocked@width
variable should override the inherited one, as is specified in LESS documentation:The overridden
@width
variable should now be inherited by the.inner-scope-test()
mixin, however, in LESS4J this is not the case.Correct output from LESS compiler
Incorrect output from LESS4J compiler
Workaround Passing the operated variable as a parameter to the inner mixin produces the correct result, however, this is less than ideal when you are dealing with multiple parameters which you then need to keep track of manually.
Output