#8815 closed bug (invalid)
jQuery's html() function removes tabs in IE 8 when it shouldn't
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | manipulation | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
See jsFiddle here:
Notice that in setting the HTML of somediv using the html() function, there are four tabs. In the latest Chrome, Safari, and Firefox, these tabs remain: i.e, there is a tab character at the beginning of each line. However, in Internet Explorer 8, all tab characters following the first are removed.
Note that I'm setting the HTML from the server that has characters saved in the data. This is for a contenteditable div used for rich text editing within my application.
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:3 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | open → closed |
I think the issue is that you're conflating HTML (where whitespace tends to be insignificant) and text/pre - where you should probably be using .text("your text") instead. You should just convert the <br>s to \n and you'll be good to go!
comment:4 Changed 12 years ago by
Why would this work correctly (correctly being that the tab is preserved) in every other browser but IE?
I can't use text() because I'm pulling HTML across the wire so it can be placed into a contenteditable div (think, text editor). To work around this, I need to add a <tab> html tag before the html() command, then replace all <tab> tags with the actual tab character. In javascript, the data flows like this:
Get data from server, with tab character -> convert to <tab> -> use html() -> convert <tab> back to tab character.
This seems like the perfect place for jQuery.
That last part should say: *tab* characters saved in the data.