Look through all scopes for a mixin before giving up. Fixes #413 again

This commit is contained in:
Luke Page
2012-10-24 20:41:32 +01:00
parent 38d2c57016
commit f3a6761dc5
3 changed files with 31 additions and 26 deletions

View File

@@ -10,14 +10,15 @@ tree.mixin.Call = function (elements, args, index, filename, important) {
};
tree.mixin.Call.prototype = {
eval: function (env) {
var mixins, args, rules = [], match = false, i, m, f, isRecursive;
var mixins, args, rules = [], match = false, i, m, f, isRecursive, isOneFound;
args = this.arguments && this.arguments.map(function (a) {
return { name: a.name, value: a.value.eval(env) };
});
for (i = 0; i < env.frames.length; i++) {
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
args = this.arguments && this.arguments.map(function (a) {
return { name: a.name, value: a.value.eval(env) };
});
isOneFound = true;
for (m = 0; m < mixins.length; m++) {
isRecursive = false;
for(f = 0; f < env.frames.length; f++) {
@@ -41,29 +42,31 @@ tree.mixin.Call.prototype = {
}
if (match) {
return rules;
} else {
throw { type: 'Runtime',
message: 'No matching definition was found for `' +
this.selector.toCSS().trim() + '(' +
(args ? args.map(function (a) {
var argValue = "";
if (a.name) {
argValue += a.name + ":";
}
if (a.value.toCSS) {
argValue += a.value.toCSS();
} else {
argValue += "???";
}
return argValue;
}).join(', ') : "") + ")`",
index: this.index, filename: this.filename };
}
}
}
throw { type: 'Name',
if (isOneFound) {
throw { type: 'Runtime',
message: 'No matching definition was found for `' +
this.selector.toCSS().trim() + '(' +
(args ? args.map(function (a) {
var argValue = "";
if (a.name) {
argValue += a.name + ":";
}
if (a.value.toCSS) {
argValue += a.value.toCSS();
} else {
argValue += "???";
}
return argValue;
}).join(', ') : "") + ")`",
index: this.index, filename: this.filename };
} else {
throw { type: 'Name',
message: this.selector.toCSS().trim() + " is undefined",
index: this.index, filename: this.filename };
}
}
};