Skip to content

Instantly share code, notes, and snippets.

@mcayland
Last active December 21, 2015 04:29
Show Gist options
  • Save mcayland/6250145 to your computer and use it in GitHub Desktop.
Save mcayland/6250145 to your computer and use it in GitHub Desktop.
HighCharts 3.0.4 IE8 createStyleSheet() fix
--- highcharts-3.0.4.js 2013-08-15 17:18:55.000000000 +0100
+++ highcharts.js 2013-09-16 17:03:19.000000000 +0100
@@ -5056,11 +5056,22 @@
doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
- // setup default css
- doc.createStyleSheet().cssText =
- 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
- '{ behavior:url(#default#VML); display: inline-block; } ';
+ // Setup default css
+ var styleSheet;
+ var hcvSelector = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke';
+ var hcvStyle = 'behavior:url(#default#VML); display: inline-block;';
+ // Append rules to existing stylesheet if one exists to avoid hitting IE's
+ // limit of 31 stylesheets per page
+ if (doc.styleSheets.length > 0) {
+ styleSheet = doc.styleSheets[0];
+ } else {
+ styleSheet = doc.createStyleSheet();
+ }
+
+ // Use .cssText rather than .addRule since .addRule breaks in quirks
+ // mode when using escaped selectors
+ styleSheet.cssText += hcvSelector + '{' + hcvStyle + '}';
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment