[OpenLayers-Trac] [OpenLayers] #3164: IE's 31-stylesheet limit and
VML.js
OpenLayers
trac-20090302 at openlayers.org
Wed Mar 9 17:48:05 EST 2011
#3164: IE's 31-stylesheet limit and VML.js
--------------------------+-------------------------------------------------
Reporter: jdege | Owner: ahocevar
Type: bug | Status: new
Priority: minor | Milestone:
Component: Renderer.VML | Version: 2.10
Keywords: | State:
--------------------------+-------------------------------------------------
Internet Explorer has a limit of 31 style sheets - whether added to the
document with a <link>, <style>, or with document.createStyleSheet().
Additional <link> or <style> are ignored, createStyleSheet() throws an
"Invalid Argument" exception
[http://msdn.microsoft.com/en-us/library/ms531194%28v=vs.85%29.aspx]
Of course, most folks will implement some sort of style sheet merging and
minifying mechanism in production, because too many style sheets is a
performance killer, but keeping separate style sheets can make development
easier.
OpenLayers calls createStyleSheet() in only one place,
Renderer.VML.initialize(). If there are 31 or more stylesheets defined on
the page, the error will occur.
Browsing around the web led me to this blog post:
[http://dean.edwards.name/weblog/2010/02/bug85/]
Comment 15 says he avoids the error by catching the exception, and
appending his new style rules to the last style sheet object:
{{{
var sheet = null;
try {
sheet = document.createStyleSheet ();
sheet.cssText = cssText;
} catch (e) {
sheet = document.styleSheets[document.styleSheets.length - 1];
sheet.cssText += "\r\n" + cssText;
}
}}}
Something of the sort should be done in OpenLayers.
--
Ticket URL: <http://trac.openlayers.org/ticket/3164>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list