r104671 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104670‎ | r104671 | r104672 >
Date:13:16, 30 November 2011
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
(bug 31212) History tab not collapsed when the screen is narrow. Patch by Michael M
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.collapsibleTabs.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.collapsibleTabs.js
@@ -24,7 +24,7 @@
2525 // if we haven't already bound our resize hanlder, bind it now
2626 if( !$.collapsibleTabs.boundEvent ) {
2727 $( window )
28 - .delayedBind( '500', 'resize', function( ) { $.collapsibleTabs.handleResize(); } );
 28+ .delayedBind( '500', 'resize', null, function( ) { $.collapsibleTabs.handleResize(); } );
2929 }
3030 // call our resize handler to setup the page
3131 $.collapsibleTabs.handleResize();

Follow-up revisions

RevisionCommit summaryAuthorDate
r104686RELEASE-NOTES for r104668, r104671, r104684catrope14:56, 30 November 2011
r105007Followup r104671: fix regression in jquery.delayedBind() due to change in par...brion21:47, 2 December 2011
r107910MFT r105010, r104671, r104576, r102137reedy17:53, 3 January 2012
r107956MFT r104030, r104033, r104146, r104671reedy22:45, 3 January 2012

Comments

#Comment by Brion VIBBER (talk | contribs)   22:56, 1 December 2011

jquery.delayedBind explicitly says that the third parameter (data) is optional, so the previous ought to work surely...? What's the reason why the patch is supposed to fix it?

#Comment by Schnark (talk | contribs)   09:11, 2 December 2011

Now after a closer look I understand what's going on: Once (jQuery 1.4.2, [1]) $.bind checked for jQuery.isFunction( data ) to see if the arguments needed to be shifted, and all worked as expected.

But with jQuery 1.6.2 ([2]) this check is now arguments.length === 2 which is false, since there are always 3 arguments, even if the last argument is undefined.

A probably better solution than my original patch would of course be to fix the delayedBind-plugin. I neither can test javascript code nor can I created patches right now, but I think something like

if ( callback === undefined ) {
 $(this).bind( '_delayedBind-' + encEvent + '-' + timeout, data );
} else {
 $(this).bind( '_delayedBind-' + encEvent + '-' + timeout, data, callback );
}

instead of line 42 should work.

Or just write in the documentation that data isn't optional any more ...

#Comment by Brion VIBBER (talk | contribs)   19:53, 2 December 2011

Aha, that makes sense!

Adding keyword needs-js-test -- we should confirm that jquery.delayedBind works with that option in the qunit tests.

#Comment by Brion VIBBER (talk | contribs)   21:49, 2 December 2011

Ok r105007 undoes this change, fixes jquery.delayedBind's optional data parameter handling, and adds a QUnit test case for delayedBind with and without the data parameter to confirm.

Should get merged to 1.18 since the updated jQuery is present there.

Status & tagging log