r78943 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78942‎ | r78943 | r78944 >
Date:01:22, 24 December 2010
Author:catrope
Status:ok
Tags:
Comment:
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>
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2579,9 +2579,18 @@
25802580 // be placed in the "other" group
25812581 $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name;
25822582 }
2583 - // Add styles to tags, user modules last
 2583+
 2584+ // We want site and user styles to override dynamically added styles from modules, but we want
 2585+ // dynamically added styles to override statically added styles from other modules. So the order
 2586+ // has to be other, dynamic, site, user
 2587+ // Add statically added styles for other modules
 2588+ $tags[] = $this->makeResourceLoaderLink( $sk, $styles['other'], 'styles' );
 2589+ // Add marker tag to mark the place where the client-side loader should inject dynamic styles
 2590+ // We use a <meta> tag with a made-up name for this because that's valid HTML
 2591+ $tags[] = Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
 2592+ // Add site and user styles
25842593 $tags[] = $this->makeResourceLoaderLink(
2585 - $sk, array_merge( $styles['other'], $styles['site'], $styles['user'] ), 'styles'
 2594+ $sk, array_merge( $styles['site'], $styles['user'] ), 'styles'
25862595 );
25872596 return implode( "\n", $tags );
25882597 }
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -482,6 +482,8 @@
483483 var suspended = true;
484484 // Flag inidicating that document ready has occured
485485 var ready = false;
 486+ // Marker element for adding dynamic styles
 487+ var $marker = $( 'head meta[name=ResourceLoaderDynamicStyles]' );
486488
487489 /* Private Methods */
488490
@@ -639,16 +641,15 @@
640642 }
641643 // Add style sheet to document
642644 if ( typeof registry[module].style === 'string' && registry[module].style.length ) {
643 - $( 'head' )
644 - .append( mediaWiki.html.element( 'style',
645 - { type: "text/css" },
 645+ $marker.before( mediaWiki.html.element( 'style',
 646+ { type: 'text/css' },
646647 new mediaWiki.html.Cdata( registry[module].style )
647648 ) );
648649 } else if ( typeof registry[module].style === 'object'
649650 && !( registry[module].style instanceof Array ) )
650651 {
651652 for ( var media in registry[module].style ) {
652 - $( 'head' ).append( mediaWiki.html.element( 'style',
 653+ $marker.before( mediaWiki.html.element( 'style',
653654 { type: 'text/css', media: media },
654655 new mediaWiki.html.Cdata( registry[module].style[media] )
655656 ) );

Sign-offs

UserFlagDate
Krinkleinspected18:40, 7 March 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r79129MFT r78011 r78014 r78015 r78016 r78099 r78117 r78161 r78170 r78172 r78199 r78......platonides19:58, 28 December 2010
r79342Merge mediawiki.js changes from r78943 that were overlooked in r79129catrope15:52, 31 December 2010

Status & tagging log