From bf0198a0295b5b4b9d5eb598ec15ab6b1eeb4f3e Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 7 Jul 2010 12:19:15 +0200 Subject: [PATCH] remove evalRules, use eval --- lib/less/tree/directive.js | 2 +- lib/less/tree/mixin.js | 6 +++--- lib/less/tree/ruleset.js | 11 ++++------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/less/tree/directive.js b/lib/less/tree/directive.js index 79779c0..6869e0a 100644 --- a/lib/less/tree/directive.js +++ b/lib/less/tree/directive.js @@ -21,7 +21,7 @@ tree.Directive.prototype = { }, eval: function (env) { env.frames.unshift(this); - this.ruleset && this.ruleset.evalRules(env); + this.ruleset && this.ruleset.eval(env); env.frames.shift(); return this; }, diff --git a/lib/less/tree/mixin.js b/lib/less/tree/mixin.js index 175f53f..8e04e4f 100644 --- a/lib/less/tree/mixin.js +++ b/lib/less/tree/mixin.js @@ -16,7 +16,7 @@ tree.mixin.Call.prototype = { if (mixins[m].match(this.arguments, env)) { try { Array.prototype.push.apply( - rules, mixins[m].eval(this.arguments, env).rules); + rules, mixins[m].eval(env, this.arguments).rules); match = true; } catch (e) { throw { message: e.message, index: e.index, stack: e.stack, call: this.index }; @@ -60,7 +60,7 @@ tree.mixin.Definition.prototype = { find: function () { return this.parent.find.apply(this, arguments) }, rulesets: function () { return this.parent.rulesets.apply(this) }, - eval: function (args, env) { + eval: function (env, args) { var frame = new(tree.Ruleset)(null, []), context; for (var i = 0, val; i < this.params.length; i++) { @@ -73,7 +73,7 @@ tree.mixin.Definition.prototype = { } } } - return new(tree.Ruleset)(null, this.rules).evalRules({ + return new(tree.Ruleset)(null, this.rules).eval({ frames: [this, frame].concat(this.frames, env.frames) }); }, diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index 571376f..974c806 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -6,17 +6,14 @@ tree.Ruleset = function (selectors, rules) { this._lookups = {}; }; tree.Ruleset.prototype = { - eval: function () { return this }, - evalRules: function (context) { + eval: function (env) { var rules = []; this.rules.forEach(function (rule) { - if (rule.evalRules) { - rules.push(rule.evalRules(context)); - } else if (rule instanceof tree.mixin.Call) { - Array.prototype.push.apply(rules, rule.eval(context)); + if (rule instanceof tree.mixin.Call) { + Array.prototype.push.apply(rules, rule.eval(env)); } else if (! (rule instanceof tree.mixin.Definition)) { - rules.push(rule.eval ? rule.eval(context) : ''); + rules.push(rule.eval ? rule.eval(env) : ''); } }); this.rules = rules;