Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#3642 closed bug (invalid)

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@…
Blocked by: Blocking:


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


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 (1)

testcase.xhtml (834 bytes) - added by jqrusr 12 years ago.
test case i used (of little interest now, i guess)

Download all attachments as: .zip

Change History (4)

comment:1 Changed 12 years ago by flesler

need: ReviewTest Case

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

comment:2 Changed 12 years ago by jqrusr

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


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 12 years ago by jqrusr

Attachment: testcase.xhtml added

test case i used (of little interest now, i guess)

comment:3 Changed 12 years ago by flesler

Resolution: invalid
Status: newclosed

Ok, thanks for the explanation. Will close it then.

Note: See TracTickets for help on using tickets.