Make the image history tree more resistant to odd structures

This commit is contained in:
Joseph Schorr 2015-04-23 14:44:08 -04:00
parent 4dff6557ae
commit 407bd0cd72

View file

@ -568,7 +568,10 @@ ImageHistoryTree.prototype.collapseNodes_ = function(node) {
var current = node;
var previous = node;
var encountered = [];
while (current.children.length == 1 && current.tags.length == 0) {
while (current.children
&& current.children.length == 1
&& curren.tags
&& current.tags.length == 0) {
encountered.push(current);
previous = current;
current = current.children[0];
@ -591,8 +594,10 @@ ImageHistoryTree.prototype.collapseNodes_ = function(node) {
}
}
for (var i = 0; i < node.children.length; ++i) {
this.collapseNodes_(node.children[i]);
if (node.children) {
for (var i = 0; i < node.children.length; ++i) {
this.collapseNodes_(node.children[i]);
}
}
};