Skip to content

Commit

Permalink
Reduce reflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Oct 8, 2015
1 parent 6cfbe18 commit 155d2c6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cq-prolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ function updateClasses(clearContainerCache) {
}
write(elementsTree);

function read(treeNodes) {
function read(treeNodes, dontMarkAsDone) {
var hasChanges = false;
treeNodes.forEach(function(node) {
if (!node._done) {
Expand All @@ -487,14 +487,11 @@ function updateClasses(clearContainerCache) {
node._changes.push([queryMatches, query]);
}
});
node._done = true;
}
if (node._changes.length) {
hasChanges = true;
}
else {
hasChanges = read(node._children);
node._done = !dontMarkAsDone;
}
hasChanges = read(node._children, dontMarkAsDone || node._changes.length)
|| node._changes.length
|| hasChanges;
});
return hasChanges;
}
Expand Down

0 comments on commit 155d2c6

Please # to comment.