Follow up r69444. Address CR comment by Simetrical.
authorPlatonides <platonides@users.mediawiki.org>
Tue, 20 Jul 2010 17:35:55 +0000 (17:35 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 20 Jul 2010 17:35:55 +0000 (17:35 +0000)
skins/common/wikibits.js

index 8ab3746..d7bd3f9 100644 (file)
@@ -325,21 +325,21 @@ function addPortletLink( portlet, href, text, id, tooltip, accesskey, nextnode )
        }
        var uls = root.getElementsByTagName( 'ul' );
        var node;
-       if (uls.length > 0) {
+       if ( uls.length > 0 ) {
                node = uls[0];
        } else {
-               node = document.createElement('ul');
-               var lc = null;
-               for (var i in root.childNodes) { /* get root.lastElementChild */
-                       if (root.childNodes[i].nodeType == 1) {
-                               lc = root.childNodes[i];
+               node = document.createElement( 'ul' );
+               var lastElementChild = null;
+               for ( var i = 0; i < root.childNodes.length; ++i ) { /* get root.lastElementChild */
+                       if ( root.childNodes[i].nodeType == 1 ) {
+                               lastElementChild = root.childNodes[i];
                        }
                }
-               if (lc && lc.nodeName.match(/div/i)) {
+               if ( lastElementChild && lastElementChild.nodeName.match( /div/i ) ) {
                        /* Insert into the menu divs */
-                       lc.appendChild(node);
+                       lastElementChild.appendChild( node );
                } else {
-                       root.appendChild(node);
+                       root.appendChild( node );
                }
        }
        if ( !node ) {