MDL-51222 javascript: Merge all the YUI instances
authorDamyon Wiese <damyon@moodle.com>
Tue, 22 Sep 2015 06:56:22 +0000 (14:56 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 22 Sep 2015 07:56:40 +0000 (15:56 +0800)
We previously had a global Y (simpleyui) and a separate Y created
to put Y in scope for all our modules. This meant that we had 2
separate sandboxes for YUI, which means that modules are duplicated,
and events do not fire across YUI instances.

This change merges the 2 instances, so any code refering to Y will
get the same instance of YUI (amd code, yui modules, static init code etc).

Thanks to Andrew Nicols!

lib/outputrequirementslib.php
lib/upgrade.txt

index e0f0962..85fb414 100644 (file)
@@ -1636,8 +1636,8 @@ class page_requirements_manager {
         $jsinit = $this->get_javascript_init_code();
         $handlersjs = $this->get_event_handler_code();
 
-        // There is no global Y, make sure it is available in your scope.
-        $js = "YUI().use('node', function(Y) {\n{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}\n});";
+        // There is a global Y, make sure it is available in your scope.
+        $js = "(function() {{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}})();";
 
         $output .= html_writer::script($js);
 
index 3ff4060..82e1b15 100644 (file)
@@ -10,6 +10,7 @@ information provided here is intended especially for developers.
   https://docs.moodle.org/dev/version.php for details (MDL-48494).
 * PHPUnit is upgraded to 4.7. Some tests using deprecated assertions etc may need changes to work correctly.
 * Users of the text editor API to manually create a text editor should call set_text before calling use_editor.
+* Javascript - SimpleYUI and the Y instance used for modules have been merged. Y is now always the same instance of Y.
 * get_referer() has been deprecated, please use the get_local_referer function instead.
 * \core\progress\null is renamed to \core\progress\none for improved PHP7 compatibility as null is a reserved word (see MDL-50453).
 * \webservice_xmlrpc_client now respects proxy server settings. If your XMLRPC server is available on your local network and not via your proxy server, you may need to add it to the list of proxy