r73674 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73673‎ | r73674 | r73675 >
Date:19:11, 24 September 2010
Author:neilk
Status:deferred
Tags:
Comment:
removing unsafe for..in over array. Clarifying when for..in used properly. (for..in is generally unsafe, and specifically, Resource Loader adds methods to Array.prototype)
Modified paths:
  • /branches/uploadwizard/extensions/UploadWizard/resources/language/mw.Parser.js (modified) (history)

Diff [purge]

Index: branches/uploadwizard/extensions/UploadWizard/resources/language/mw.Parser.js
@@ -19,8 +19,8 @@
2020 * @param {Object} magicSet key:callback
2121 */
2222 mw.addTemplateTransform = function( magicSet ) {
23 - for ( var i in magicSet ) {
24 - pMagicSet[ i ] = magicSet[i];
 23+ for ( var name in magicSet ) {
 24+ pMagicSet[name] = magicSet[name];
2525 }
2626 };
2727
@@ -111,7 +111,7 @@
112112 paramSet.splice( 0, 1 );
113113 if ( paramSet.length ) {
114114 templateObject.param = new Array();
115 - for ( var pInx in paramSet ) {
 115+ for ( var pInx = 0; pInx < paramSet.length; pInx++ ) {
116116 var paramString = paramSet[ pInx ];
117117 // check for empty param
118118 if ( paramString == '' ) {
@@ -206,7 +206,7 @@
207207
208208 if ( node['child'] ) {
209209 // swap all the kids:
210 - for ( var i in node['child'] ) {
 210+ for ( var i = 0; i < node['child'].length; i++ ) {
211211 var nodeText = recurse_magic_swap( node['child'][i] );
212212 // swap it into current
213213 if ( node.text ) {
@@ -249,7 +249,7 @@
250250 var tmplSet = new Array();
251251 function getMatchingTmpl( node ) {
252252 if ( node['child'] ) {
253 - for ( var i in node['child'] ) {
 253+ for ( var i = 0; i < node['child'].length; i++ ) {
254254 getMatchingTmpl( node['child'] );
255255 }
256256 }
@@ -320,4 +320,4 @@
321321 }
322322 };
323323
324 -}) ( window.mw );
\ No newline at end of file
 324+}) ( window.mw );

Status & tagging log