mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
refactored variable lookup
This commit is contained in:
@@ -3,21 +3,19 @@ if (typeof(window) === 'undefined') { var tree = require(require('path').join(__
|
||||
tree.Variable = function Variable(name) { this.name = name };
|
||||
tree.Variable.prototype = {
|
||||
eval: function (env) {
|
||||
var variables, variable;
|
||||
for (var i = 0; i < env.frames.length; i++) {
|
||||
variables = env.frames[i].variables();
|
||||
var variable, name = this.name;
|
||||
|
||||
for (var j = 0; j < variables.length; j++) {
|
||||
variable = variables[j];
|
||||
|
||||
if (variable.name === this.name) {
|
||||
if (variable.value.eval) {
|
||||
return variable.value.eval(env);
|
||||
} else { return variable.value }
|
||||
if (variable = env.frames.find(function (frame) {
|
||||
return frame.variables().find(function (variable) {
|
||||
if (variable.name === name) {
|
||||
return variable.value.eval ? variable.value.eval(env)
|
||||
: variable.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
})) { return variable }
|
||||
else {
|
||||
throw new(Error)("variable " + this.name + " is undefined");
|
||||
}
|
||||
throw new(Error)("variable " + this.name + " is undefined");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user