Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2579,9 +2579,18 @@ |
2580 | 2580 | // be placed in the "other" group |
2581 | 2581 | $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name; |
2582 | 2582 | } |
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 |
2584 | 2593 | $tags[] = $this->makeResourceLoaderLink( |
2585 | | - $sk, array_merge( $styles['other'], $styles['site'], $styles['user'] ), 'styles' |
| 2594 | + $sk, array_merge( $styles['site'], $styles['user'] ), 'styles' |
2586 | 2595 | ); |
2587 | 2596 | return implode( "\n", $tags ); |
2588 | 2597 | } |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -482,6 +482,8 @@ |
483 | 483 | var suspended = true; |
484 | 484 | // Flag inidicating that document ready has occured |
485 | 485 | var ready = false; |
| 486 | + // Marker element for adding dynamic styles |
| 487 | + var $marker = $( 'head meta[name=ResourceLoaderDynamicStyles]' ); |
486 | 488 | |
487 | 489 | /* Private Methods */ |
488 | 490 | |
— | — | @@ -639,16 +641,15 @@ |
640 | 642 | } |
641 | 643 | // Add style sheet to document |
642 | 644 | 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' }, |
646 | 647 | new mediaWiki.html.Cdata( registry[module].style ) |
647 | 648 | ) ); |
648 | 649 | } else if ( typeof registry[module].style === 'object' |
649 | 650 | && !( registry[module].style instanceof Array ) ) |
650 | 651 | { |
651 | 652 | for ( var media in registry[module].style ) { |
652 | | - $( 'head' ).append( mediaWiki.html.element( 'style', |
| 653 | + $marker.before( mediaWiki.html.element( 'style', |
653 | 654 | { type: 'text/css', media: media }, |
654 | 655 | new mediaWiki.html.Cdata( registry[module].style[media] ) |
655 | 656 | ) ); |