r107164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107163‎ | r107164 | r107165 >
Date:17:03, 23 December 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
[Core JS] scan all /phase3/, change certain constructors to literals
* new String, new Boolean, new Number
-- should not be used since they don't compare very well:
; 5 !== new Number( 5 ) // true
; !!new Boolean( false ) // true, objects are truethy
-- If type conversion is intended, they should be used as
functions instead of constructors.
* new Array, new Object
-- literals are shorter, no point in not using them.
Modified paths:
  • /trunk/phase3/skins/common/mwsuggest.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/mwsuggest.js
@@ -30,8 +30,8 @@
3131 // delay between keypress and suggestion (in ms)
3232 window.os_search_timeout = 250;
3333 // these pairs of inputs/forms will be autoloaded at startup
34 -window.os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText');
35 -window.os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' );
 34+window.os_autoload_inputs = ['searchInput', 'searchInput2', 'powerSearchText', 'searchText'];
 35+window.os_autoload_forms = ['searchform', 'searchform2', 'powersearch', 'search'];
3636 // if we stopped the service
3737 window.os_is_stopped = false;
3838 // max lines to show in suggest table
@@ -423,7 +423,7 @@
424424 }
425425 s.setAttribute( 'list', r.container );
426426
427 - r.results = new Array();
 427+ r.results = [];
428428 r.resultCount = results.length;
429429 r.visible = true;
430430 for ( i = 0; i < results.length; i++ ) {
@@ -643,7 +643,7 @@
644644 var c = document.getElementById( r.container );
645645 var width = c.offsetWidth - os_operaWidthFix( c.offsetWidth );
646646 var html = '<table class="os-suggest-results" id="' + r.resultTable + '" style="width: ' + width + 'px;">';
647 - r.results = new Array();
 647+ r.results = [];
648648 r.resultCount = results.length;
649649 for( i = 0; i < results.length; i++ ) {
650650 var title = os_decodeValue( results[i] );

Comments

#Comment by Nikerabbit (talk | contribs)   14:37, 24 December 2011

Did you intend to commit more files?

#Comment by Krinkle (talk | contribs)   23:16, 24 December 2011

Yes and no. I was expecting more files to contain these, but fortunately this was the only one. I wrote the commit message before I did the find/replace.

Status & tagging log