Below loop runs once for i=0, then indefinitely for i=1 into a browser crash, i.e. i does not increment:
cascadeComponent: function(item, fn, scope) {
if (fn.call(scope || this, item) !== false) {
if (item.items) {
for (i = 0; i < item.items.items.length; i++) {
this.cascadeComponent(item.items.items[i], fn, scope);
}
}
}
}
I can avoid the issue by using the frameworks iteration loop. Alternatively I have the same loop working with the slight difference that the array is found in item.items vs. item.items.items.
Any ideas why that happens? It’s the same in Chrome and Firefox.
You are using a global
ivariable. Add this line at the start of the function:Otherwise each recursive call resets
ito 0 for all invocations ofcascadeComponent.