Last modified: 2006-12-14 23:27:00 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T10264, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 8264 - JavaScript global variables fail in XHTML mode
JavaScript global variables fail in XHTML mode
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.9.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: html
  Show dependency treegraph
 
Reported: 2006-12-14 23:05 UTC by Brion Vibber
Modified: 2006-12-14 23:27 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Brion Vibber 2006-12-14 23:05:04 UTC
While setting $wgMimeType to application/xhtml+xml to enforce XHTML
well-formedness for testing, I noticed that there seem to be some regressions
where JavaScript behavior doesn't work correctly:

* wgBreakFrames check on all page views
* mwEditButtons when building toolbar in edit view


Found this to happen in following browsers:
* Firefox 2.0, Mac and Windows
* Firefox 1.5, Mac
* Opera 9, Mac

The variables, defined respectively inline in a <script> element and in
wikibits.js, don't appear to be visible in the subroutines that use them.
'Undefined variable' or 'has no properties' errors result.

Opera's error messages:

name: ReferenceError
message: Statement on line 51: Reference to undefined variable: wgBreakFrames
Backtrace:
  Line 51 of linked script http://katitzi.local/trunk/skins/common/wikibits.js?33
    if (wgBreakFrames)

name: TypeError
message: Statement on line 341: Could not convert undefined or null to object
Backtrace:
  Line 341 of linked script http://katitzi.local/trunk/skins/common/wikibits.js?33
    mwEditButtons[mwEditButtons.length] = {imageFile : imageFile, speedTip :
speedTip, tagOpen : tagOpen, tagClose : tagClose, sampleText : sampleText};
  Line 3 of inline#1 script in
http://katitzi.local/trunk/index.php?title=Main_Page&action=edit
    addButton("/trunk/skins/common/images/button_bold.png", "Bold text", "'''",
"'''", "Bold text");

Offhand I don't see anything wrong with the code; it seems correct to me and as
far as I know should work fine in XHTML mode just as it does in HTML 4 mode
(text/html mime-type).

Removing the 'var' on the declaration in wikibits.js does not appear to have any
effect for mwEditButtons.
Comment 1 Brion Vibber 2006-12-14 23:27:00 UTC
Fixed in r18342.

When the inline global variable definition block got expanded, the <script>
contents got wrapped in old-style //<!-- HTML comment blocks.

That's incompatible with XHTML as parsed by a proper XML parser, since the
contents really do get removed before being passed to the JavaScript
interpreter.

Browsers so old they don't understand <script> blocks also don't understand
name-based virtual hosts and don't have a prayer at reaching a typical modern
MediaWiki-based web site, so there's no need to use that technique.

Removed the comment blocks, and replaced it with a /*<![CDATA[*/ /*]]>*/
wrapper to ensure that contents aren't misinterpreted in XHTML mode.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links