From 48cf5926b888336895fdcc78792f8d24ee7f3b24 Mon Sep 17 00:00:00 2001 From: Austin Hyde Date: Wed, 22 Jan 2014 11:44:20 -0500 Subject: [PATCH] Fix IIFE invoking Canvas APIs that don't exist in early IE Changed ol.interaction.Draw.defaultStyleFunction to be a getter, so that it only calls Canvas APIs when needed, rather than on script load --- src/ol/interaction/drawinteraction.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index b1bef46f70..96df0f93a3 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -148,18 +148,16 @@ ol.interaction.Draw = function(opt_options) { */ this.overlay_ = new ol.render.FeaturesOverlay(); this.overlay_.setStyleFunction(goog.isDef(opt_options.styleFunction) ? - opt_options.styleFunction : ol.interaction.Draw.defaultStyleFunction + opt_options.styleFunction : ol.interaction.Draw.getDefaultStyleFunction() ); }; goog.inherits(ol.interaction.Draw, ol.interaction.Interaction); /** - * @param {ol.Feature} feature Feature. - * @param {number} resolution Resolution. - * @return {Array.} Styles. + * @return {ol.feature.StyleFunction} Styles. */ -ol.interaction.Draw.defaultStyleFunction = (function() { +ol.interaction.Draw.getDefaultStyleFunction = function() { /** @type {Object.>} */ var styles = {}; styles[ol.geom.GeometryType.POLYGON] = [ @@ -210,7 +208,7 @@ ol.interaction.Draw.defaultStyleFunction = (function() { return function(feature, resolution) { return styles[feature.getGeometry().getType()]; }; -})(); +}; /**