SelectFeature and OpenLayers.Feature.Vector.style["select"]: changed Control.SelectFeature to inherit properties that are not set in selectStyle from feature.style. r=tschaub (closes #1260)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5896 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
}
|
||||
|
||||
function test_Control_SelectFeature_select(t) {
|
||||
t.plan(2);
|
||||
t.plan(7);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
@@ -45,6 +45,32 @@
|
||||
t.eq(feature.style.strokeColor, OpenLayers.Feature.Vector.style['select'].strokeColor, "feature style is set to select style");
|
||||
control.unselect(feature);
|
||||
t.eq(feature.style.strokeColor, OpenLayers.Feature.Vector.style['default'].strokeColor, "feature style is set back to old style");
|
||||
|
||||
// Don't ever overwrite my feature style with undefined properties from the selectStyle
|
||||
feature.style = {externalGraphic: "foo.png", pointRadius: 39};
|
||||
control.selectStyle.pointRadius = undefined;
|
||||
control.select(feature);
|
||||
t.eq(feature.style.pointRadius, 39, "undefined style property inherited from original feature style");
|
||||
control.unselect(feature);
|
||||
|
||||
// Ok, that one went well. But I'm sure you cannot handle OL.Style.
|
||||
feature.style = new OpenLayers.Style({externalGraphic: "foo.png", pointRadius: 39});
|
||||
control.select(feature);
|
||||
t.eq(feature.style.pointRadius, 39, "undefined style property inherited from original feature style object");
|
||||
control.unselect(feature);
|
||||
|
||||
// Wow, but using OL.Style as selectStyle will break you.
|
||||
control.selectStyle = new OpenLayers.Style({strokeColor: "green"});
|
||||
control.select(feature);
|
||||
t.eq(feature.style.strokeColor, "green", "style correct if both feature.style and selectStyle are OL.Style");
|
||||
control.unselect(feature);
|
||||
|
||||
// Not bad, not bad. And what if I set feature.style back to a style hash?
|
||||
feature.style = layer.style;
|
||||
control.select(feature);
|
||||
t.eq(feature.style.strokeColor, "green", "style still correct with only selectStyle being OL.Style");
|
||||
control.unselect(feature);
|
||||
t.eq(feature.style.strokeColor, OpenLayers.Feature.Vector.style["default"].strokeColor, "style set back to original correctly");
|
||||
}
|
||||
|
||||
function test_Control_SelectFeature_activate(t) {
|
||||
|
||||
Reference in New Issue
Block a user