Don't use for (i in array) in JavaScript
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 00:11:48 +0000 (00:11 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 00:11:48 +0000 (00:11 +0000)
This reportedly can cause errors, because it will return all object
attributes, not just array elements.  Use a C-style for here instead.
This could be done in other places too -- the immediate motive here is
that this might be related:

http://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Sortable_tables_.26_Firefox_3.0.5

The functionality seems to still work.

skins/common/wikibits.js

index 3421aee..089d22d 100644 (file)
@@ -661,7 +661,7 @@ function ts_resortTable(lnk) {
                span.setAttribute('sortdir','down');
        }
 
-       for(var i in staticRows) {
+       for (var i = 0; i < staticRows.length; i++) {
                var row = staticRows[i];
                newRows.splice(row[2], 0, row);
        }