Skip to content
This repository

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

Open
ibolmo opened this Issue January 29, 2012 · 2 comments

2 participants

Olmo Maldonado Arian Stolwijk
Olmo Maldonado
Owner

Here's the fix: https://github.com/mootools/mootools-core/pull/2263/files#L1R21

(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…
…ldIE

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.
d09b487
Arian Stolwijk
Owner

I made this fix https://github.com/arian/mootools-core/compare/fix-2265-style-text

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
Owner

@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.