r112371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112370‎ | r112371 | r112372 >
Date:23:32, 24 February 2012
Author:krinkle
Status:ok
Tags:
Comment:
[mw.loader] Remove 'media' type support in addInlineCSS

* This was never used in practice because the server only gives css text strings for media type "" or "all". Because server side concatenates everything together during pre-processing and e.g. print-stylesheet parts of it are wrapped in @media print {}

* Follows-up r110988
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -421,7 +421,7 @@
422422 return s;
423423 }
424424
425 - function addInlineCSS( css, media ) {
 425+ function addInlineCSS( css ) {
426426 var $style, style, $newStyle;
427427 $style = getMarker().prev();
428428 if ( $style.is( 'style' ) && $style.data( 'ResourceLoaderDynamicStyleTag' ) === true ) {
@@ -435,7 +435,6 @@
436436 }
437437 } else {
438438 $newStyle = $( addStyleTag( css, getMarker() ) )
439 - .attr( 'media', media )
440439 .data( 'ResourceLoaderDynamicStyleTag', true );
441440 }
442441 }
@@ -728,19 +727,19 @@
729728
730729 // Add styles
731730 if ( $.isPlainObject( registry[module].style ) ) {
 731+ // 'media' type ignored, see documentation of mw.loader.implement
732732 for ( media in registry[module].style ) {
733733 style = registry[module].style[media];
734734 if ( $.isArray( style ) ) {
735735 for ( i = 0; i < style.length; i += 1 ) {
736736 getMarker().before( mw.html.element( 'link', {
737737 'type': 'text/css',
738 - 'media': media,
739738 'rel': 'stylesheet',
740739 'href': style[i]
741740 } ) );
742741 }
743742 } else if ( typeof style === 'string' ) {
744 - addInlineCSS( style, media );
 743+ addInlineCSS( style );
745744 }
746745 }
747746 }
@@ -1112,7 +1111,12 @@
11131112 * @param script Mixed: Function of module code or String of URL to be used as the src
11141113 * attribute when adding a script element to the body
11151114 * @param style Object: Object of CSS strings keyed by media-type or Object of lists of URLs
1116 - * keyed by media-type
 1115+ * keyed by media-type. Media-type should be "all" or "", actual types are not supported
 1116+ * right now due to the way execute() processes the stylesheets (they are concatenated
 1117+ * into a single <style> tag). In the past these weren't concatenated together (which is
 1118+ * these are keyed by media-type), but bug 31676 forces us to. In practice this is not a
 1119+ * problem because ResourceLoader only generates stylesheets for media-type all (e.g. print
 1120+ * stylesheets are wrapped in @media print {} and concatenated with the others).
11171121 * @param msgs Object: List of key/value pairs to be passed through mw.messages.set
11181122 */
11191123 implement: function ( module, script, style, msgs ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110988(bug 31676) Group dynamically inserted CSS into a single <style> tag, because...catrope00:10, 9 February 2012

Status & tagging log