Simple fix to KML style parsing (from Edgemaster). This change makes getStyle

return clones. Since the results of getStyle are extended later in the code
by the inlineStyle, this fixes a case where kml.styleUrl symbolizers can 
be changed by <Style> blocks attached to features which share a style.
r=me. (Closes #1578)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@8776 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-01-28 02:07:09 +00:00
parent 256f027c7c
commit 32ca128b18
2 changed files with 10 additions and 1 deletions

View File

@@ -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;
},

View File

@@ -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");
}
</script>
</head>