new Element('style', {text: ''}) throws IE exception #2265

ibolmo opened this Issue Jan 30, 2012 · 2 comments


None yet
2 participants

ibolmo commented Jan 30, 2012

Here's the fix:

(and btw, we need to update those lines once we're done)

IE doesn't like innerHTMl or innerText for stylesheet definitions. Instead we need to use styleSheet.cssText to set the text.

@ghost ghost assigned arian Feb 4, 2012

arian added a commit to arian/mootools-core that referenced this issue Feb 4, 2012

Fixes #2265 - Using .set('text', '…') on <style> elements failed in …

The feature detection tests actually tries to set the CSS, this is done
because IE9 does not fail, but supports the styleSheet property.
So this way IE9 behaves like other browsers.

arian commented Feb 4, 2012

I made this fix

One issue still remains, using IE8:

var style = new Element('style', {type: 'text/css'});
console.log(style.styleSheet); // undefined

While using

var style = document.createElement('style');
style.type = 'text/css';
console.log(style.styleSheet); // object

ibolmo commented Feb 6, 2012

@arian any luck on this?

@ibolmo ibolmo modified the milestones: 1.5.1, 1.5 Mar 3, 2014

@ibolmo ibolmo closed this in #2622 Jul 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment