Really fix bug 26131: just putting the site+user <link> at the bottom of the <head> isn't good enough if the client-side loader is gonna add dynamically populated <style> tags below it later, so we need those dynamic <style> tags to go before the site+user <link> but after the skin <link>. Make OutputPage insert a <meta> tag between these two, marking the spot for the client side load which inserts dynamic <style> tags above this <meta> tag rather than at the end of the <head>
This commit is contained in:
parent
881cdf4aea
commit
b2a808d87b
2 changed files with 16 additions and 6 deletions
|
|
@ -2579,9 +2579,18 @@ class OutputPage {
|
|||
// be placed in the "other" group
|
||||
$styles[isset( $styles[$group] ) ? $group : 'other'][] = $name;
|
||||
}
|
||||
// Add styles to tags, user modules last
|
||||
|
||||
// We want site and user styles to override dynamically added styles from modules, but we want
|
||||
// dynamically added styles to override statically added styles from other modules. So the order
|
||||
// has to be other, dynamic, site, user
|
||||
// Add statically added styles for other modules
|
||||
$tags[] = $this->makeResourceLoaderLink( $sk, $styles['other'], 'styles' );
|
||||
// Add marker tag to mark the place where the client-side loader should inject dynamic styles
|
||||
// We use a <meta> tag with a made-up name for this because that's valid HTML
|
||||
$tags[] = Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
|
||||
// Add site and user styles
|
||||
$tags[] = $this->makeResourceLoaderLink(
|
||||
$sk, array_merge( $styles['other'], $styles['site'], $styles['user'] ), 'styles'
|
||||
$sk, array_merge( $styles['site'], $styles['user'] ), 'styles'
|
||||
);
|
||||
return implode( "\n", $tags );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,6 +482,8 @@ window.mediaWiki = new ( function( $ ) {
|
|||
var suspended = true;
|
||||
// Flag inidicating that document ready has occured
|
||||
var ready = false;
|
||||
// Marker element for adding dynamic styles
|
||||
var $marker = $( 'head meta[name=ResourceLoaderDynamicStyles]' );
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
|
|
@ -639,16 +641,15 @@ window.mediaWiki = new ( function( $ ) {
|
|||
}
|
||||
// Add style sheet to document
|
||||
if ( typeof registry[module].style === 'string' && registry[module].style.length ) {
|
||||
$( 'head' )
|
||||
.append( mediaWiki.html.element( 'style',
|
||||
{ type: "text/css" },
|
||||
$marker.before( mediaWiki.html.element( 'style',
|
||||
{ type: 'text/css' },
|
||||
new mediaWiki.html.Cdata( registry[module].style )
|
||||
) );
|
||||
} else if ( typeof registry[module].style === 'object'
|
||||
&& !( registry[module].style instanceof Array ) )
|
||||
{
|
||||
for ( var media in registry[module].style ) {
|
||||
$( 'head' ).append( mediaWiki.html.element( 'style',
|
||||
$marker.before( mediaWiki.html.element( 'style',
|
||||
{ type: 'text/css', media: media },
|
||||
new mediaWiki.html.Cdata( registry[module].style[media] )
|
||||
) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue