when evaluating a mixin, compile all matches, instead of just the first one

This commit is contained in:
cloudhead
2010-03-03 22:13:14 -05:00
parent a1c8d50699
commit 4aea44f8f8
2 changed files with 9 additions and 5 deletions

View File

@@ -10,9 +10,9 @@ tree.mixin.Call.prototype = {
var mixin, rules = [];
for (var i = 0; i < env.frames.length; i++) {
if (mixin = env.frames[i].find(this.selector)) {
for (var r = 0; r < mixin.rules.length; r++) {
rules.push(mixin.rules[r]);
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
for (var m = 0; m < mixins.length; m++) {
Array.prototype.push.apply(rules, mixins[m].rules);
}
return rules;
}

View File

@@ -12,11 +12,15 @@ tree.Ruleset.prototype = {
},
mixable: function (fun) {
return this.rules.filter(function (r) {
if (r instanceof tree.mixin.Definition || r instanceof tree.Ruleset) { return r }
if (r instanceof tree.mixin.Definition || r instanceof tree.Ruleset) {
if (typeof(fun) === 'function') {
return fun.call(this, r);
} else { return r }
}
});
},
find: function (selector) {
return this.mixable().find(function (rule) {
return this.mixable(function (rule) {
for (var j = 0; j < rule.selectors.length; j++) {
if (selector.elements[0].value === rule.selectors[j].elements[0].value) {
if (selector.elements.length > 1) {