id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,state
3164,IE's 31-stylesheet limit and VML.js,jdege,ahocevar,"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.


",bug,new,minor,,Renderer.VML,2.10,,,,
