Bug Tracker

Modify

Ticket #6223 (closed bug: wontfix)

Opened 3 years ago

Last modified 3 years ago

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

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)

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to wontfix
  • Component changed from unfiled to manipulation

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 3 years ago by jahabdank

  • Status changed from closed to reopened
  • Resolution wontfix deleted

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 3 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to wontfix

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.