ResourceLoader::makeLoaderImplementScript: Bind args as '$' and 'jQuery'
authorOri Livneh <ori@wikimedia.org>
Sun, 9 Mar 2014 10:19:25 +0000 (03:19 -0700)
committerKrinkle <krinklemail@gmail.com>
Fri, 11 Apr 2014 18:15:11 +0000 (18:15 +0000)
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

RELEASE-NOTES-1.23
includes/resourceloader/ResourceLoader.php

index 947a0d6..79c692a 100644 (file)
@@ -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)
index 77659f6..eac6a02 100644 (file)
@@ -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.' );
                }