jenkins-bot has submitted this change and it was merged.
Change subject: Replace native "document.write" with deprecated fallback
......................................................................
Replace native "document.write" with deprecated fallback
In most browsers, calling "document.write" after the document is
ready results in the document being re-created with the specified
content (effectively replacing with blank page).
While this is a browser issue, mitigate this by replacing the
method with a fallback (wrapped in "mw.log.deprecate") that just
appends the given HTML to the document body.
Note that scripts do not execute when appended as HTML, they will
become dormant elements. It'll work for raw content as a basic
fallback, but it should become apparent to the end user that the
code needs to be upgraded.
Bug: T108139
Change-Id: Ic9056d7a779f234a28ddad005fd4d76f2e750fcc
---
M resources/src/mediawiki.legacy/wikibits.js
1 file changed, 6 insertions(+), 0 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/src/mediawiki.legacy/wikibits.js
b/resources/src/mediawiki.legacy/wikibits.js
index 32cd79a..1f01110 100644
--- a/resources/src/mediawiki.legacy/wikibits.js
+++ b/resources/src/mediawiki.legacy/wikibits.js
@@ -215,4 +215,10 @@
win.importScript = importScript;
win.importStylesheet = importStylesheet;
+ // Replace document.write 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.' );
+
}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/229619
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9056d7a779f234a28ddad005fd4d76f2e750fcc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Edokter <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits