r79246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79245‎ | r79246 | r79247 >
Date:12:22, 30 December 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 26507) Wrap all ResourceLoader-served JS in (function($, mw) { code here })(jQuery, mediaWiki) so modules can always use $ as an alias for jQuery even if it's been unset in the global scope with jQuery.noConflict()
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -533,7 +533,7 @@
534534 'mediaWiki.loader.implement',
535535 array(
536536 $name,
537 - new XmlJsCode( "function() {{$scripts}}" ),
 537+ new XmlJsCode( "function( $, mw ) {{$scripts}}" ),
538538 (object)$styles,
539539 (object)$messages
540540 ) );
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -661,7 +661,7 @@
662662 }
663663 // Execute script
664664 try {
665 - registry[module].script();
 665+ registry[module].script( jQuery, mediaWiki );
666666 registry[module].state = 'ready';
667667 // Run jobs who's dependencies have just been met
668668 for ( var j = 0; j < jobs.length; j++ ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r797191.17: MFT r78078, r78285, r78787, r79246, r79358, r79480, r79481, r79491, r79...catrope14:15, 6 January 2011
r79929Removing unneeded wraps and using $ and mw instead of jQuery or mediaWiki sin...krinkle05:33, 10 January 2011

Comments

#Comment by Catrope (talk | contribs)   13:45, 10 January 2011

Per https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Special:Code/MediaWiki/79929#c12900 this is not as useful as I thought it would be at first, because it doesn't work in debug mode. So this revision can't be used to defend removing existing function($){ ... }(jQuery); wraps.

Status & tagging log