Skip to main content

Bug Tracker

Side navigation

#5977 closed bug (fixed)

Opened January 29, 2010 04:04AM UTC

Closed February 13, 2010 08:31AM UTC

Last modified July 29, 2010 03:57PM UTC

.html() will strip <style> tags in IE

Reported by: cmcnulty Owned by:
Priority: major Milestone: 1.4.2
Component: manipulation Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:
Description

see http://forum.jquery.com/topic/html-stripping-style-in-ie-sometimes for discussion.

when using .html() to insert the following html snippet:

"<style type="text/css">

.test { color: red; }

</style>

<div id="nav_controls" class="navControls">

<div id="test_div" class="test">A test</div>

</div>

"

innerHTML will strip the <style> tags and content, in IE8. The bug can be a bit tricky to reproduce, as the criteria for stripping the style seems to have something to do with preceding whitespace.

I can't reproduce in FF3.6 or Chrome 3. Untested in IE7 or earlier

Attachments (1)
  • test.html (0.8 KB) - added by cmcnulty January 29, 2010 04:04AM UTC.

    test case

Change History (3)

Changed February 13, 2010 08:31AM UTC by john comment:1

component: unfiledmanipulation
resolution: → fixed
status: newclosed

Changed July 16, 2010 03:30PM UTC by cmcnulty comment:2

For the record, the exact same problem exists for <link> with the exact same symptoms, and the exact same work-arounds (inserting a <br/> before the tag)

Changed July 29, 2010 03:57PM UTC by cmcnulty comment:3

When the <style> or <link> tags are preceded with any of the following text, IE will *not* strip the <style/link> tag (non-exhaustive list):

  • <br/>
  •  
  • <span>asdf</span>
  • <div>asdf</div>
  • asdf

IE *will* strip the <style/link> tags if preceded by any of these:

  • carriage returns
  • multiple blank spaces
  • <div></div> (empty div)
  • <span></span> (empty span)