Override document.writeln to prevent it from blanking pages
authorOri Livneh <ori@wikimedia.org>
Sat, 8 Aug 2015 01:25:55 +0000 (18:25 -0700)
committerOri Livneh <ori@wikimedia.org>
Sat, 8 Aug 2015 01:26:39 +0000 (18:26 -0700)
Follow-up for Ic9056d7a77. Same rationale.

Bug: T108423
Change-Id: I664ba9b0af4355ac83f2e5892e484a3f3aff0428

resources/src/mediawiki.legacy/wikibits.js

index 1f01110..05954ff 100644 (file)
        win.importScript = importScript;
        win.importStylesheet = importStylesheet;
 
-       // Replace document.write with basic html parsing that appends
+       // Replace document.write/writeln with basic html parsing that appends
        // to the <body> to avoid blanking pages. Added JavaScript will not run.
-       mw.log.deprecate( document, 'write', function ( html ) {
-               $( 'body' ).append( $.parseHTML( html ) );
-       }, 'Use jQuery or mw.loader.load instead.' );
+       $.each( [ 'write', 'writeln' ], function ( idx, method ) {
+               mw.log.deprecate( document, method, function ( html ) {
+                       $( 'body' ).append( $.parseHTML( html ) );
+               }, 'Use jQuery or mw.loader.load instead.' );
+       } );
 
 }( mediaWiki, jQuery ) );