From cb1972b4ae4adc58413f00f6af8e09a48f608983 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 27 Feb 2012 22:33:14 +0000 Subject: [PATCH] (bug 34542) Calling mw.loader.load('http://someurlhere') sometimes calls document.write() from inside an asynchronously loaded script. This is because we added the async parameter in 1.19, and made it default to false, which works for 1.18 HTML but doesn't work for user/site/Gadget JS written for 1.18 . So make the async parameter default to true when a URL is passed and to false otherwise. This is kind of evil but it's the only sane way of preserving b/c that I can think of --- resources/mediawiki/mediawiki.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index 509d6cacf6..6fcf615b57 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -1206,7 +1206,8 @@ var mw = ( function ( $, undefined ) { * "text/javascript"; if no type is provided, text/javascript is assumed. * @param async {Boolean} (optional) If true, load modules asynchronously * even if document ready has not yet occurred. If false (default), - * block before document ready and load async after + * block before document ready and load async after. If not set, true will + * be assumed if loading a URL, and false will be assumed otherwise. */ load: function ( modules, type, async ) { var filtered, m; @@ -1219,6 +1220,10 @@ var mw = ( function ( $, undefined ) { if ( typeof modules === 'string' ) { // Support adding arbitrary external scripts if ( /^(https?:)?\/\//.test( modules ) ) { + if ( async === undefined ) { + // Assume async for bug 34542 + async = true; + } if ( type === 'text/css' ) { $( 'head' ).append( $( '', { rel: 'stylesheet', -- 2.20.1