mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
cache ruleset lookup
This commit is contained in:
@@ -14,16 +14,20 @@ tree.Ruleset.prototype = {
|
||||
});
|
||||
}
|
||||
},
|
||||
rulesets: function () {
|
||||
if (this._rulesets) { return this._rulesets }
|
||||
else {
|
||||
return this._rulesets = this.rules.filter(function (r) {
|
||||
if (r instanceof tree.Ruleset || r instanceof tree.mixin.Definition) { return r }
|
||||
});
|
||||
}
|
||||
},
|
||||
find: function (selector, self) {
|
||||
self = self || this;
|
||||
var rules = [], rule, match;
|
||||
|
||||
for (var i = 0; i < this.rules.length; i++) {
|
||||
rule = this.rules[i];
|
||||
|
||||
if ((rule instanceof tree.mixin.Definition ||
|
||||
rule instanceof tree.Ruleset) && rule !== self) {
|
||||
|
||||
this.rulesets().forEach(function (rule) {
|
||||
if (rule !== self) {
|
||||
for (var j = 0; j < rule.selectors.length; j++) {
|
||||
if (match = selector.match(rule.selectors[j])) {
|
||||
if (selector.elements.length > 1) {
|
||||
@@ -36,8 +40,8 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rules
|
||||
});
|
||||
return rules;
|
||||
},
|
||||
//
|
||||
// Entry point for code generation
|
||||
|
||||
Reference in New Issue
Block a user