[OpenLayers-Users] VML.js and IE's 31 style sheet limit

Jeff Dege jeff.dege at korterra.com
Tue Mar 8 13:27:53 EST 2011


IE has a limit of 31 style sheets, whether created with <style>, <link>, or document.createStyleSheet.

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.

We have a page that is hitting the limit, and the error is occurring in the VML renderer of a Vector Layer.

OpenLayers.Renderer.VML.intialize() contains:

    var style = document.createStyleSheet();

And this throws an exception, if there are already 31 style sheets on the page.

Browsing around on the issue led me to this blog entry:

   http://dean.edwards.name/weblog/2010/02/bug85/

Comment 15 says that he avoids the error by appending his new style rules to the last style sheet object, when creating a new one throws an error:

   var sheet = null;
   try {
      sheet = document.createStyleSheet ();
      sheet.cssText = cssText;
   } catch (e) {
      sheet = document.styleSheets[document.styleSheets.length - 1];
      sheet.cssText += "\r\n" + cssText;
   }

I'm wondering if this might be a good idea in OpenLayers.

Thoughts?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110308/4e256cb9/attachment.html


More information about the Users mailing list