Skip to main content

Bug Tracker

Side navigation

#3642 closed bug (invalid)

Opened November 24, 2008 03:43PM UTC

Closed November 25, 2008 11:32PM UTC

Last modified March 14, 2012 11:54PM UTC

reliance on .innerHTML breaks jquery in Firefox 3 when used with XHTML

Reported by: jqrusr Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: xhtml, innerhtml Cc: jqrusr.7.n1@dfgh.net
Blocked by: Blocking:
Description

Details on this behavior can be found on the web, for example at

http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_in_xh.html

Using .innerHTML breaks on XHTML pages in Firefox 3 (and maybe 2, not tested). The proper way to insert content is using DOM methods like createElement() in this case. At the moment, this prevents jquery from being used fully with XHTML compliant pages.

A fix should be simple. There are only six lines in jquery 1.2.6 where innerHTML is used, two of those are comments. Three only read the attribute (which still works, even on FF), and the only problematic (because it's setting innerHTML) line seems to be line 993:

div.innerHTML = wrap[1] + elem + wrap[2];

A quick workaround would be rewriting that line to not use innerHTML. In the long run, replacing the other three lines and avoiding .innerHTML will help jquery a great deal to make it fun to use with XHTML.

Attachments (0)
Change History (3)

Changed November 25, 2008 11:26AM UTC by flesler comment:1

need: ReviewTest Case

Can you provide a test case ? a minimalistic html file with the requires html and js to reproduce the problem.

Changed November 25, 2008 11:18PM UTC by jqrusr comment:2

Unfortunately, it is not a jquery issue. I've experienced the bug and implemented a workaround, but after a while it seemed to be gone even in my "broken" version. I've searched the web and found that the bug (Firefox not supporting .innerHTML) was present in Firefox 1.5 and below - but is supposed to be fixed in any later versions.

It seems more likely that I've triggered a rare regression in Firefox than a bug in jquery. While .innerHTML is still non-standard, it seems to be present almost everywhere, so I guess avoiding it is a non-issue.

This seems to be the real problem: I have been using markItUp, which has an extra quote in the code (it's just a single quote character that should not be there). See

http://plugins.jquery.com/node/4986

for details. This extra quote causes .wrap() to be called with invalid markup.

Firefox 3 handles .innerHTML in XHTML just fine, but only with valid markup in the innerHTML. The extra quote causes something like <code><div "></code> to be set as the innerHTML which THEN causes the exception.

The bug is obviously a Firefox issue (since they decided to support innerHTML), and I may file a bug report at their tracker as well.

Changed November 25, 2008 11:32PM UTC by flesler comment:3

resolution: → invalid
status: newclosed

Ok, thanks for the explanation.

Will close it then.