From 0c50dfb76dd841671d8f33fb5f83e2409de6293d Mon Sep 17 00:00:00 2001 From: Josh Schmidt Date: Tue, 17 Dec 2013 22:42:04 -0700 Subject: [PATCH] Use parent ids instead of recursive calls to inInheritanceChain() --- lib/less/extend-visitor.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/less/extend-visitor.js b/lib/less/extend-visitor.js index e711f028..4b397a98 100644 --- a/lib/less/extend-visitor.js +++ b/lib/less/extend-visitor.js @@ -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; },