(bug 31676) Group dynamically inserted CSS into a single <style> tag, because IE...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 9 Feb 2012 00:10:50 +0000 (00:10 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 9 Feb 2012 00:10:50 +0000 (00:10 +0000)
RELEASE-NOTES-1.19
resources/mediawiki/mediawiki.js

index ce0c471..c7a3387 100644 (file)
@@ -245,6 +245,8 @@ production.
 * It is now possible to delete images that have no corresponding description pages.
 * (bug 33165) GlobalFunctions.php line 1312: Call to a member function
   getText() on a non-object
+* (bug 31676) Group dynamically inserted CSS into a single <style> tag, to work
+  around a bug where not all styles were applied in Internet Explorer
 
 === API changes in 1.19 ===
 * Made action=edit less likely to return "unknownerror", by returning the actual error
index bac53b6..ccd3407 100644 (file)
@@ -375,7 +375,7 @@ var mw = ( function ( $, undefined ) {
        
                        /* Private methods */
        
-                       function getMarker(){
+                       function getMarker() {
                                // Cached ?
                                if ( $marker ) {
                                        return $marker;
@@ -389,6 +389,27 @@ var mw = ( function ( $, undefined ) {
                                        return $marker;
                                }
                        }
+                       
+                       function addInlineCSS( css, media ) {
+                               var $style = getMarker().prev();
+                               if ( $style.is( 'style' ) && $style.data( 'ResourceLoaderDynamicStyleTag' ) === true ) {
+                                       // There's already a dynamic <style> tag present, append to it
+                                       // This recycling of <style> tags is for bug 31676 (can't have
+                                       // more than 32 <style> tags in IE)
+                                       
+                                       // Do cdata sanitization on the provided CSS, and prepend a double newline
+                                       css = $( mw.html.element( 'style', {}, new mw.html.Cdata( "\n\n" + css ) ) ).html();
+                                       $style.append( css );
+                               } else {
+                                       // Create a new <style> tag and insert it
+                                       $style = $( mw.html.element( 'style', {
+                                                       'type': 'text/css',
+                                                       'media': media
+                                               }, new mw.html.Cdata( css ) ) );
+                                       $style.data( 'ResourceLoaderDynamicStyleTag', true );
+                                       getMarker().before( $style );
+                               }
+                       }
        
                        function compare( a, b ) {
                                var i;
@@ -686,10 +707,7 @@ var mw = ( function ( $, undefined ) {
                                                                } ) );
                                                        }
                                                } else if ( typeof style === 'string' ) {
-                                                       getMarker().before( mw.html.element( 'style', {
-                                                               'type': 'text/css',
-                                                               'media': media
-                                                       }, new mw.html.Cdata( style ) ) );
+                                                       addInlineCSS( style, media );
                                                }
                                        }
                                }