Skip to content

Commit

Permalink
perf: Speed up getNodeFromTree (#1302)
Browse files Browse the repository at this point in the history
* fix: speed up getNodeFromTree

* remove return value for clear semantics

* fix early return nit
  • Loading branch information
paulirish authored and WilcoFiers committed Jan 9, 2019
1 parent b9d1b57 commit 5f834ed
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/core/utils/flattened-tree.js
Expand Up @@ -142,15 +142,13 @@ axe.utils.getNodeFromTree = function(vNode, node) {
return vNode;
}
vNode.children.forEach(candidate => {
var retVal;

if (found) {
return;
}
if (candidate.actualNode === node) {
found = candidate;
} else {
retVal = axe.utils.getNodeFromTree(candidate, node);
if (retVal) {
found = retVal;
}
found = axe.utils.getNodeFromTree(candidate, node);
}
});
return found;
Expand Down

0 comments on commit 5f834ed

Please sign in to comment.