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 comment:1
component: | unfiled → manipulation |
---|---|
milestone: | None → 1.next |
priority: | undecided → low |
status: | new → open |
Changed December 18, 2011 08:09PM UTC by 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 September 05, 2012 02:17AM UTC by comment:5
keywords: | → 1.9-discuss |
---|
Changed September 24, 2012 04:50PM UTC by comment:6
+1, This seems pretty fixable for 1.9 (.text()
only) and doesn't need to be in 2.0.
Changed October 14, 2012 10:17PM UTC by comment:8
+1, yup
Changed October 29, 2012 04:46PM UTC by comment:9
+1, If there's a fix and it's not huge, lets fix it.
Changed October 29, 2012 04:46PM UTC by comment:10
milestone: | 1.next → 1.9 |
---|
Changed November 21, 2012 06:02PM UTC by comment:11
#12909 is a duplicate of this ticket.
Changed December 03, 2012 05:09PM UTC by comment:12
owner: | → rwaldron |
---|---|
status: | open → assigned |
Changed December 03, 2012 06:02PM UTC by comment:13
resolution: | → wontfix |
---|---|
status: | assigned → closed |
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 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 comment:15
#15183 is a duplicate of this ticket.
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.