Use parent ids instead of recursive calls to inInheritanceChain()

This commit is contained in:
Josh Schmidt
2013-12-17 22:42:04 -07:00
parent 7a5e4327d5
commit 0c50dfb76d

View File

@@ -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;
},