mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
Use parent ids instead of recursive calls to inInheritanceChain()
This commit is contained in:
@@ -125,7 +125,7 @@
|
||||
targetExtend = extendsListTarget[targetExtendIndex];
|
||||
|
||||
// look for circular references
|
||||
if (this.inInheritanceChain(targetExtend, extend)) { continue; }
|
||||
if( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ){ continue; }
|
||||
|
||||
// find a match in the target extends self selector (the bit before :extend)
|
||||
selectorPath = [targetExtend.selfSelectors[0]];
|
||||
@@ -151,7 +151,7 @@
|
||||
newExtend.ruleset = targetExtend.ruleset;
|
||||
|
||||
//remember its parents for circular references
|
||||
newExtend.parents = [targetExtend, extend];
|
||||
newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids);
|
||||
|
||||
// only process the selector once.. if we have :extend(.a,.b) then multiple
|
||||
// extends will look at the same selector path, so when extending
|
||||
@@ -187,20 +187,6 @@
|
||||
return extendsToAdd;
|
||||
}
|
||||
},
|
||||
inInheritanceChain: function (possibleParent, possibleChild) {
|
||||
if (possibleParent === possibleChild) {
|
||||
return true;
|
||||
}
|
||||
if (possibleChild.parents) {
|
||||
if (this.inInheritanceChain(possibleParent, possibleChild.parents[0])) {
|
||||
return true;
|
||||
}
|
||||
if (this.inInheritanceChain(possibleParent, possibleChild.parents[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visitRule: function (ruleNode, visitArgs) {
|
||||
visitArgs.visitDeeper = false;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user