Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6223 closed bug (wontfix)

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:


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)

Change History (3)

comment:1 Changed 13 years ago by john

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).

comment:2 Changed 13 years ago by jahabdank

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

comment:3 Changed 13 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.