diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js index 68a41ce0ac..73ed1eb2dd 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -663,7 +663,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { } // return requested style - var style = this.styles[styleUrl]; + var style = OpenLayers.Util.extend({}, this.styles[styleUrl]); return style; }, diff --git a/tests/Format/KML.html b/tests/Format/KML.html index c16bbb7c78..0b123d4326 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -143,6 +143,15 @@ var features = f.read(test_style_fill); t.eq(features[0].style.fillColor, "none", "KML Feature has none fill"); } + function test_Format_KML_getStyle(t) { + t.plan(1); + var style = {t: true}; + var f = new OpenLayers.Format.KML(); + f.styles = {test: style}; + var gotStyle = f.getStyle('test'); + gotStyle.t = false; + t.ok(style.t, "getStyle returns copy of style rather than reference"); + }