make mixins behave like closures
This commit is contained in:
parent
00df4e97d0
commit
4bb4c97357
@ -52,6 +52,7 @@ tree.mixin.Definition = function (name, params, rules) {
|
||||
else { return count }
|
||||
}, 0);
|
||||
this.parent = tree.Ruleset.prototype;
|
||||
this.frames = [];
|
||||
};
|
||||
tree.mixin.Definition.prototype = {
|
||||
toCSS: function () { return "" },
|
||||
@ -73,7 +74,7 @@ tree.mixin.Definition.prototype = {
|
||||
}
|
||||
}
|
||||
return new(tree.Ruleset)(null, this.rules).evalRules({
|
||||
frames: [this, frame].concat(env.frames)
|
||||
frames: [this, frame].concat(this.frames, env.frames)
|
||||
});
|
||||
},
|
||||
match: function (args, env) {
|
||||
|
@ -108,6 +108,8 @@ tree.Ruleset.prototype = {
|
||||
if (this.rules[i] instanceof tree.mixin.Call) {
|
||||
Array.prototype.splice
|
||||
.apply(this.rules, [i, 1].concat(this.rules[i].eval(env)));
|
||||
} else if (this.rules[i] instanceof tree.mixin.Definition) {
|
||||
this.rules[i].frames = env.frames.slice(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user