r83300 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83299‎ | r83300 | r83301 >
Date:17:06, 5 March 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Follow-up r83280; looks like I accidentally deprecated a piece of legacy JS :D
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/skins/common/htmlform.js (deleted) (history)

Diff [purge]

Index: trunk/phase3/skins/common/htmlform.js
@@ -1,36 +0,0 @@
2 -// Find select-or-other fields.
3 -addOnloadHook( function() {
4 - var fields = getElementsByClassName( document, 'select', 'mw-htmlform-select-or-other' );
5 -
6 - for( var i = 0; i < fields.length; i++ ) {
7 - var select = fields[i];
8 -
9 - addHandler( select, 'change', htmlforms.selectOrOtherSelectChanged );
10 -
11 - // Use a fake 'e' to update it.
12 - htmlforms.selectOrOtherSelectChanged( { 'target': select } );
13 - }
14 -} );
15 -
16 -window.htmlforms = {
17 - 'selectOrOtherSelectChanged' : function( e ) {
18 - var select;
19 - if ( !e ) {
20 - e = window.event;
21 - }
22 - if ( e.target ) {
23 - select = e.target;
24 - } else if ( e.srcElement ) {
25 - select = e.srcElement;
26 - }
27 - if ( select.nodeType == 3 ) { // defeat Safari bug
28 - select = select.parentNode;
29 - }
30 -
31 - var id = select.id;
32 - var textbox = document.getElementById( id + '-other' );
33 -
34 - textbox.disabled = ( select.value != 'other' );
35 - }
36 -};
37 -
Index: trunk/phase3/includes/HTMLForm.php
@@ -54,7 +54,6 @@
5555 * TODO: Document 'section' / 'subsection' stuff
5656 */
5757 class HTMLForm {
58 - static $jsAdded = false;
5958
6059 # A mapping of 'type' inputs onto standard HTMLFormField subclasses
6160 static $typeMappings = array(
@@ -160,15 +159,10 @@
161160 /**
162161 * Add the HTMLForm-specific JavaScript, if it hasn't been
163162 * done already.
 163+ * @deprecated @since 1.18 load modules with ResourceLoader instead
164164 */
165 - static function addJS() {
166 - if ( self::$jsAdded ) return;
 165+ static function addJS() { }
167166
168 - global $wgOut;
169 -
170 - $wgOut->addModules( 'mediawiki.legacy.htmlform' );
171 - }
172 -
173167 /**
174168 * Initialise a new Object for the field
175169 * @param $descriptor input Descriptor, as described above
@@ -202,9 +196,6 @@
203197 throw new MWException( "You must call setTitle() on an HTMLForm" );
204198 }
205199
206 - // FIXME shouldn't this be closer to displayForm() ?
207 - self::addJS();
208 -
209200 # Load data from the request.
210201 $this->loadData();
211202 }
Index: trunk/phase3/resources/Resources.php
@@ -544,12 +544,6 @@
545545 'localBasePath' => "{$GLOBALS['IP']}/skins",
546546 'dependencies' => 'mediawiki.legacy.wikibits',
547547 ),
548 - 'mediawiki.legacy.htmlform' => array(
549 - 'scripts' => 'common/htmlform.js',
550 - 'remoteBasePath' => $GLOBALS['wgStylePath'],
551 - 'localBasePath' => "{$GLOBALS['IP']}/skins",
552 - 'dependencies' => 'mediawiki.legacy.wikibits',
553 - ),
554548 'mediawiki.legacy.IEFixes' => array(
555549 'scripts' => 'common/IEFixes.js',
556550 'remoteBasePath' => $GLOBALS['wgStylePath'],
@@ -581,7 +575,7 @@
582576 'scripts' => 'common/prefs.js',
583577 'remoteBasePath' => $GLOBALS['wgStylePath'],
584578 'localBasePath' => "{$GLOBALS['IP']}/skins",
585 - 'dependencies' => array( 'mediawiki.legacy.wikibits', 'mediawiki.legacy.htmlform' ),
 579+ 'dependencies' => array( 'mediawiki.legacy.wikibits', 'mediawiki.htmlform' ),
586580 ),
587581 'mediawiki.legacy.preview' => array(
588582 'scripts' => 'common/preview.js',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83280Follow-up r83183, r83202:...happy-melon12:48, 5 March 2011

Comments

#Comment by Krinkle (talk | contribs)   21:42, 9 June 2011

htmlforms and selectOrOtherSelectChanged weren't referenced anywhere else in /trunk. JS part is OK.



+	 * @deprecated @since 1.18 load modules with ResourceLoader instead
 	 */
-	static function addJS() {
-		if ( self::$jsAdded ) return;
+	static function addJS() { }

The end result is now this.

The method is now broken, not deprecated. Deprecated means it should no longer be used and will be removed in the future, right now it will silently fail without anyone easily being able to trace why. Marking FIXME.

#Comment by Happy-melon (talk | contribs)   23:41, 9 June 2011

In r83280 I (among other things) added a new RL-ified module mediawiki.htmlform. In this revision I realised that the old mediawiki.legacy.htmlform module was now entirely redundant to that new code and so removed it, leaving HTMLForm::addJS() with no function; calling it achieves nothing both before and after this revision, so no functionality is altered by stubbing it. In fact, the $jsAdded check was unnecessary since the introduction of RL anyway; the addJS() call could have just unconditionally called $wgOut->addModules().

There are no remaining calls to HtmlForm::addJS() anywhere in SVN, but just in case there are any out in the wild, I left the stub in for a release rather than immediately removing it completely.

Unless I'm missing something fundamental, I fail to see how this is in any way broken.

#Comment by Krinkle (talk | contribs)   00:15, 10 June 2011

Ah, I see. Thanks for the quick response. Marking OK.

Status & tagging log