Permalink
Browse files

Fix for IE<=9 when >=31 stylesheets are already loaded

  • Loading branch information...
1 parent 85fdaca commit 843dfd5e44cb6cc5e4d2d1a913215f74bf045dbb @gwatts committed Jul 30, 2013
Showing with 19 additions and 7 deletions.
  1. +4 −0 Changelog.txt
  2. +14 −6 src/utils.js
  3. +1 −1 version.txt
View
@@ -1,6 +1,10 @@
jQuery Sparkline Plugin ChangeLog
http://omnipotent.net/jquery.sparkline/
+2.1.x ???
+
++ Fix for IE <= 9 for loading CSS when 31 stylesheets are already present
+
2.1.2 15/June/2013
View
@@ -202,14 +202,22 @@
// http://paulirish.com/2008/bookmarklet-inject-new-css-rules/
addCSS = function(css) {
- var tag;
- //if ('\v' == 'v') /* ie only */ {
+ var tag, iefail;
if (document.createStyleSheet) {
- document.createStyleSheet().cssText = css;
+ try {
+ document.createStyleSheet().cssText = css;
+ return;
+ } catch (e) {
+ // IE <= 9 maxes out at 31 stylesheets; inject into page instead.
+ iefail = true;
+ }
+ }
+ tag = document.createElement('style');
+ tag.type = 'text/css';
+ document.getElementsByTagName('head')[0].appendChild(tag);
+ if (iefail) {
+ document.styleSheets[document.styleSheets.length - 1].cssText = css;
} else {
- tag = document.createElement('style');
- tag.type = 'text/css';
- document.getElementsByTagName('head')[0].appendChild(tag);
tag[(typeof document.body.style.WebkitAppearance == 'string') /* webkit only */ ? 'innerText' : 'innerHTML'] = css;
}
};
View
@@ -1 +1 @@
-2.1.2
+2.1.3

0 comments on commit 843dfd5

Please sign in to comment.