[Xsltforms-support] XSLTForms and for(var i in list) construct
Brought to you by:
alain-couthures
From: Leigh L K. Jr <lei...@xe...> - 2011-01-11 19:44:09
|
In a few places, XSLTForms uses for(var i in list). This construct is not recommended for iteration over arrays. See https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in and other sources. This JavaScript idiom fail when prototype.js is loaded. Below is my best guess at which lines are in error. I've not tested them all, but at least dispatchList works now. $ diff -u xsltforms.js.orig xsltforms.js.new --- xsltforms.js.orig 2011-01-05 14:29:26.000000000 -0800 +++ xsltforms.js.new 2011-01-11 11:42:25.100306926 -0800 @@ -1166,7 +1166,7 @@ } if (this.callstack) { - for (var i in this.callstack) { + for (var i = 0, len = this.callstack.length; i < len; i++) { DebugConsole.write("> " + this.callstack[i]); } } @@ -1791,7 +1791,7 @@ return res; }, clear : function() { - for (var i in this.data) { + for (var i = 0, len = this.data.lengt; i < len; i++) { this.data[i] = null; } @@ -7056,8 +7056,8 @@ XMLEvents.dispatchList = function(list, name) { - for (var id in list) { - XMLEvents.dispatch(list[id], name); + for (var i = 0, len = list.length; i < len; i++) { + XMLEvents.dispatch(list[i], name); } }; @@ -7103,7 +7103,7 @@ ancestors.unshift(a); } - for (var i in ancestors) { + for (var i = 0, len = ancestors.length; i < len; i++) { var event = document.createEventObject(); event.trueName = name; event.phase = "capture"; @@ -9869,4 +9869,4 @@ - \ No newline at end of file + |