Skip to main content

Bug Tracker

Side navigation

#9832 closed bug (wontfix)

Opened July 15, 2011 10:34AM UTC

Closed December 03, 2012 06:02PM UTC

Last modified July 14, 2014 01:55AM UTC

text(), html() and append() don't work on <style> elements in IE8

Reported by: paul.dixon@mintbridge.co.uk Owned by: rwaldron
Priority: low Milestone: 1.9
Component: manipulation Version: 1.6.2
Keywords: 1.9-discuss Cc:
Blocked by: Blocking:
Description

Trying to add a style definition using a style element throws an exception in Internet Explorer 8. I tried using text(), html() and append() but they all give the same error:

Line: 192

Error: Object doesn't support this property or method

Example at http://jsfiddle.net/BdU9u/

Attachments (0)
Change History (15)

Changed July 15, 2011 01:30PM UTC by timmywil comment:1

component: unfiledmanipulation
milestone: None1.next
priority: undecidedlow
status: newopen

Confirmed

http://jsfiddle.net/timmywil/BdU9u/2/

However, this works: http://jsfiddle.net/timmywil/VdmYD/1/

So it may be that style elements are readonly in IE.

Changed December 18, 2011 08:09PM UTC by anonymous comment:2

It's a known bug. appendChild on <style> element throws exceptions. To workaround this issue use

var style = document.createElement('style');
style.styleSheet.cssText = 'h1 { color: blue; }';

http://stackoverflow.com/questions/436710/element-appendchild-chokes-in-ie

http://www.quirksmode.org/bugreports/archives/2006/01/IE_wont_allow_documentcreateElementstyle.html

Changed March 19, 2012 08:39AM UTC by sindresorhus comment:3

#11486 is a duplicate of this ticket.

Changed September 05, 2012 02:15AM UTC by mikesherov comment:4

#12406 is a duplicate of this ticket.

Changed September 05, 2012 02:17AM UTC by mikesherov comment:5

keywords: → 1.9-discuss

Changed September 24, 2012 04:50PM UTC by dmethvin comment:6

+1, This seems pretty fixable for 1.9 (.text() only) and doesn't need to be in 2.0.

Changed October 09, 2012 01:00PM UTC by gibson042 comment:7

#12679 is a duplicate of this ticket.

Changed October 14, 2012 10:17PM UTC by mikesherov comment:8

+1, yup

Changed October 29, 2012 04:46PM UTC by gnarf comment:9

+1, If there's a fix and it's not huge, lets fix it.

Changed October 29, 2012 04:46PM UTC by mikesherov comment:10

milestone: 1.next1.9

Changed November 21, 2012 06:02PM UTC by dmethvin comment:11

#12909 is a duplicate of this ticket.

Changed December 03, 2012 05:09PM UTC by rwaldron comment:12

owner: → rwaldron
status: openassigned

Changed December 03, 2012 06:02PM UTC by rwaldron comment:13

resolution: → wontfix
status: assignedclosed

text() is implemented via Sizzle and adding a special case to Sizzle.getText where: elem is style and only in oldIE, return the elem.style.cssText is unreasonable. Considering we don't need this in jQuery 2.0, Sizzle shouldn't have to carry the burden.

Changed September 09, 2013 08:14PM UTC by gern comment:14

For those of you that dont take "no" as an answer :

$.fn.extend({
  'text': function (value) {
    return $.access(this, function (value) {
      if (value === undefined)
        return $.text(this);
      if (this[0] && this[0].nodeName == 'STYLE') {
        if (this[0].styleSheet) this[0].styleSheet.cssText = value;
        else this[0].innerHTML = value;
        return this;
      }
      return this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
    }, null, value, arguments.length);
  }
});

Changed July 14, 2014 01:55AM UTC by gibson042 comment:15

#15183 is a duplicate of this ticket.