Skip to content
This repository

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

ibolmo opened this Issue January 29, 2012 · 2 comments

2 participants

Olmo Maldonado Arian Stolwijk
Olmo Maldonado

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.

Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

Arian Stolwijk arian referenced this issue from a commit in arian/mootools-core February 05, 2012
Arian Stolwijk Fixes #2265 - Using .set('text', '…') on <style> elements failed in o…

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 Stolwijk

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
Olmo Maldonado

@arian any luck on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.