Skip to main content

Bug Tracker

Side navigation

#6223 closed bug (wontfix)

Opened March 04, 2010 04:52PM UTC

Closed April 16, 2010 12:32AM UTC

html() not browser agnostic. Returns ids and classes without qoutes in IE

Reported by: slubowsky Owned by:
Priority: Milestone: 1.4.3
Component: manipulation Version: 1.4.2
Keywords: html Cc:
Blocked by: Blocking:
Description

Calling .html() on an element containing something like

<div id="foo" class="bar"></div>

returns very different strings depending on the browser.

In firefox you get pretty much what you expect, in IE (8 but also when using IE 8 in IE 7 mode) you get

<DIV id=foo class=bar></DIV>

The quotes are gone (and capitalization is different)

Attachments (0)
Change History (3)

Changed March 04, 2010 08:01PM UTC by john comment:1

component: unfiledmanipulation
resolution: → wontfix
status: newclosed

Correct - we don't make guarantees about the returned content - we do make sure that the returned result can, at least, still be injected into the page (fixing any particularly malformed HTML that might be returned).

Changed April 15, 2010 10:25PM UTC by jahabdank comment:2

resolution: wontfix
status: closedreopened

I personally think that this is not a correct approach - jquery should correct this error. In my team we just have wasted an entire workday of 3 programmers, before we have figured out it is IE problem. Jquery should at least offer a secondary function like clear_html() which would return html exactly as it is, and warn on the website that this error might happen.

You would not even have to write such a function - there are ready open source implementations e.g.:

http://www.stevetucker.co.uk/page-innerxhtml.php

If you look at the example in this link you will see that the <li> elements are malformed too (so it is not only quotes and capital letters).

Just incorporate it in JQuery core. I am 100% sure hundreds of other developers have wasted a lot of time on that error. At least warn about it on the doc page!

Thanks in advance,

Jozef

Changed April 16, 2010 12:32AM UTC by dmethvin comment:3

resolution: → wontfix
status: reopenedclosed

It's just not practical to change this. We're aware of innerxhtml but it's extremely slow. If you want to prove this, stop using jQuery's native .html() and use innerxhtml instead in all your code.

I have added a comment regarding IE's problems in the documentation.