mirror of
https://github.com/less/less.js.git
synced 2026-02-09 22:45:28 -05:00
do not pollute the parent scope after mixin call if variable is defined
This commit is contained in:
@@ -47,7 +47,15 @@ tree.Ruleset.prototype = {
|
||||
// Evaluate mixin calls.
|
||||
for (var i = 0; i < ruleset.rules.length; i++) {
|
||||
if (ruleset.rules[i] instanceof tree.mixin.Call) {
|
||||
rules = ruleset.rules[i].eval(env);
|
||||
rules = ruleset.rules[i].eval(env).filter(function(r) {
|
||||
if ((r instanceof tree.Rule) && r.variable) {
|
||||
// do not pollute the scope if the variable is
|
||||
// already there. consider returning false here
|
||||
// but we need a way to "return" variable from mixins
|
||||
return !(ruleset.variable(r.name));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
ruleset.rules.splice.apply(ruleset.rules, [i, 1].concat(rules));
|
||||
i += rules.length-1;
|
||||
ruleset.resetCache();
|
||||
|
||||
Reference in New Issue
Block a user