From: Ori Livneh Date: Sun, 9 Mar 2014 10:19:25 +0000 (-0700) Subject: ResourceLoader::makeLoaderImplementScript: Bind args as '$' and 'jQuery' X-Git-Tag: 1.31.0-rc.0~16218^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=5742c1f38527;p=lhc%2Fweb%2Fwiklou.git ResourceLoader::makeLoaderImplementScript: Bind args as '$' and 'jQuery' Make the function that wraps ResourceLoader modules bind the first and second arguments it receives to '$' and 'jQuery'. This patch is a follow-up to change I0c9edac35, which updated the invocation of mw.loader#implement so that it passes jQuery as the first and second argument. Change-Id: I0f0c3a04c3b0e6a28115a10bf11a2a78aca66c21 --- diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 947a0d611e..79c692abe6 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -337,6 +337,13 @@ changes to languages because of Bugzilla reports. * The locations of resources have been split between upstream libraries, now in resources/lib/, local libaries in resources/src/, and local forks of upstream libraries, also in resources/src/. +* BREAKING CHANGE: The automatically-generated function closure with which + ResourceLoader wraps all modules' JavaScript code now binds the identifier + names 'jQuery' and '$' to the jQuery object of the version of jQuery that is + bundled with MediaWiki. If you bind these names to other objects in global + scope (like Zepto.js or document.querySelectorAll, for example) you will need + to use different names to or re-bind them at the top of each + ResourceLoader-loaded module. ==== Removed classes ==== * FakeMemCachedClient (deprecated in 1.18) diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 77659f68eb..eac6a02f63 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -935,7 +935,7 @@ class ResourceLoader { */ public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) { if ( is_string( $scripts ) ) { - $scripts = new XmlJsCode( "function () {\n{$scripts}\n}" ); + $scripts = new XmlJsCode( "function ( $, jQuery ) {\n{$scripts}\n}" ); } elseif ( !is_array( $scripts ) ) { throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' ); }