mediawiki.loader: Better document IE stylesheet limit bug
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 4 Mar 2014 19:18:58 +0000 (20:18 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 4 Mar 2014 19:18:58 +0000 (20:18 +0100)
Also leave a comment on the line where the relevant exception
will be thrown from if it does end up hitting the limit still
(which wouldn't be due to mw.loader appending more than 31
stylesheets but due to there being more than 30 on the page
already).

Change-Id: I3a46affc5498fbaa1d442ca65cb4844dd8f8169c

resources/mediawiki/mediawiki.js

index 8a50363..9bb86af 100644 (file)
@@ -767,11 +767,11 @@ var mw = ( function ( $, undefined ) {
                                        return;
                                }
 
-                               // By default, always create a new <style>. Appending text
-                               // to a <style> tag means the contents have to be re-parsed (bug 45810).
-                               // Except, of course, in IE below 9, in there we default to
-                               // re-using and appending to a <style> tag due to the
-                               // IE stylesheet limit (bug 31676).
+                               // By default, always create a new <style>. Appending text to a <style>
+                               // tag is bad as it means the contents have to be re-parsed (bug 45810).
+                               //
+                               // Except, of course, in IE 9 and below. In there we default to re-using and
+                               // appending to a <style> tag due to the IE stylesheet limit (bug 31676).
                                if ( 'documentMode' in document && document.documentMode <= 9 ) {
 
                                        $style = getMarker().prev();
@@ -1138,11 +1138,14 @@ var mw = ( function ( $, undefined ) {
                                 */
                                function addLink( media, url ) {
                                        var el = document.createElement( 'link' );
-                                       getMarker().before( el ); // IE: Insert in dom before setting href
+                                       // For IE: Insert in document *before* setting href
+                                       getMarker().before( el );
                                        el.rel = 'stylesheet';
                                        if ( media && media !== 'all' ) {
                                                el.media = media;
                                        }
+                                       // If you end up here from an IE exception "SCRIPT: Invalid property value.",
+                                       // see #addEmbeddedCSS, bug 31676, and bug 47277 for details.
                                        el.href = url;
                                }