Skip to content

Commit 04d2d3a

Browse files
author
cloudhead
committed
make mixins behave like closures
1 parent 64cca1f commit 04d2d3a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/less/tree/mixin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ tree.mixin.Definition = function (name, params, rules) {
5252
else { return count }
5353
}, 0);
5454
this.parent = tree.Ruleset.prototype;
55+
this.frames = [];
5556
};
5657
tree.mixin.Definition.prototype = {
5758
toCSS: function () { return "" },
@@ -73,7 +74,7 @@ tree.mixin.Definition.prototype = {
7374
}
7475
}
7576
return new(tree.Ruleset)(null, this.rules).evalRules({
76-
frames: [this, frame].concat(env.frames)
77+
frames: [this, frame].concat(this.frames, env.frames)
7778
});
7879
},
7980
match: function (args, env) {

lib/less/tree/ruleset.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ tree.Ruleset.prototype = {
108108
if (this.rules[i] instanceof tree.mixin.Call) {
109109
Array.prototype.splice
110110
.apply(this.rules, [i, 1].concat(this.rules[i].eval(env)));
111+
} else if (this.rules[i] instanceof tree.mixin.Definition) {
112+
this.rules[i].frames = env.frames.slice(0);
111113
}
112114
}
113115

0 commit comments

Comments
 (0)