Page MenuHomePhabricator

document.write() breaks under application/xhtml+xml in skins/common/wikibits.js
Closed, ResolvedPublic


Author: damien

When using the 'application/xhtml+xml' content type document.write() function do not work
in 'skins/common/wikibits.js'. You should instead use the DOM.

I use this to select the content type based on the browser's HTTP_ACCEPT:

$wgMimeType = in_array('application/xhtml+xml', array_map('trim', explode(',',
$_SERVER['HTTP_ACCEPT']))) ? 'application/xhtml+xml' : 'text/html';

I will include a patch, but I will not work on (at least not anytime soon) addButton() or
addInfobox() as I currently do not understand them. I first noticed this bug concerning
the DOM with showTocToggle().

The patch has had the showTocToggle() tested on Opera 7.54u2, Mozilla Firefox 1.0.2 and
Internet Explorer 6. The 'special stylesheet links' has not been tested.

In addition to this bug, Opera should use document.createElementNS() rather than document.
createElement(). Internet Explorer does not support document.createElementNS, so a check
should be performed before using it. This was first discovered in tabbedprefs(), which has
also been included in the patch and tested.

Version: 1.4.x
Severity: normal
OS: Windows XP
Platform: PC



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:30 PM
bzimport set Reference to bz2186.
bzimport added a subscriber: Unknown Object (MLST).

damien wrote:

Proposed patch for bug 2186

Version 1 Patch by Damien Bezborodow. Further notes included in comments.
Compare with the current file of 1.4.4 to see my changes.

attachment wikibits.js ignored as obsolete

Please make sure you're working from CVS HEAD, *not* the 1.4 release branch.

damien wrote:

Bug 2186 patch

This has been updated to be relevent to the CVS head. There are still some
instances of document.write() that need to be removed.

The use of document.createElementNS() will solve issues in Opera, but they may
not work in HTML.

Furthermore this script will need testing. If the current version works on the
CVS version, then this should too.

attachment wikibits_cvs_revision1.9_patched.js ignored as obsolete

Created attachment 4978
Updated patch

Updated patch to remove the last of the document.write()'s in wikibits. These are all <link> CSS, so I made a new function called appendLinkedCss() to add new child DOM objects to the head.

Just want some review, as Javascript isn't my strongest.


Shouldn't this just use importStylesheetURI() instead of creating a new function to do the same thing?