From 5742c1f385271dadaca454163ad8db4b49bf1e91 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Sun, 9 Mar 2014 03:19:25 -0700 Subject: [PATCH] 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 --- RELEASE-NOTES-1.23 | 7 +++++++ includes/resourceloader/ResourceLoader.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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.' ); } -- 2.20.1