give the wfs layer a proper destroy method (Closes #1256)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5989 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -156,6 +156,24 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
} else {
|
||||
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
||||
}
|
||||
if (this.tile) {
|
||||
this.tile.destroy();
|
||||
}
|
||||
this.tile = null;
|
||||
|
||||
this.ratio = null;
|
||||
this.featureClass = null;
|
||||
this.format = null;
|
||||
|
||||
if (this.formatObject && this.formatObject.destroy) {
|
||||
this.formatObject.destroy();
|
||||
}
|
||||
this.formatObject = null;
|
||||
|
||||
this.formatOptions = null;
|
||||
this.vectorMode = null;
|
||||
this.encodeBBOX = null;
|
||||
this.extractAttributes = null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,68 @@
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_WFS_destroy(t) {
|
||||
t.plan(13);
|
||||
|
||||
var tVectorDestroy = OpenLayers.Layer.Vector.prototype.destroy;
|
||||
OpenLayers.Layer.Vector.prototype.destroy = function() {
|
||||
g_VectorDestroyed = true;
|
||||
}
|
||||
|
||||
var tMarkersDestroy = OpenLayers.Layer.Markers.prototype.destroy;
|
||||
OpenLayers.Layer.Markers.prototype.destroy = function() {
|
||||
g_MarkersDestroyed = true;
|
||||
}
|
||||
|
||||
var layer = {
|
||||
'vectorMode': true,
|
||||
'tile': {
|
||||
'destroy': function() {
|
||||
t.ok(true, "wfs layer's tile is destroyed");
|
||||
}
|
||||
},
|
||||
'ratio': {},
|
||||
'featureClass': {},
|
||||
'format': {},
|
||||
'formatObject': {
|
||||
'destroy': function() {
|
||||
t.ok(true, "wfs layer's format object is destroyed");
|
||||
}
|
||||
},
|
||||
'formatOptions': {},
|
||||
'encodeBBOX': {},
|
||||
'extractAttributes': {}
|
||||
};
|
||||
|
||||
//this call should set off two tests (destroys for tile and format object)
|
||||
g_VectorDestroyed = null;
|
||||
g_MarkersDestroyed = null;
|
||||
OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []);
|
||||
|
||||
t.ok(g_VectorDestroyed && !g_MarkersDestroyed, "when vector mode is set to true, the default vector layer's destroy() method is called");
|
||||
t.eq(layer.vectorMode, null, "'vectorMode' property nullified");
|
||||
t.eq(layer.tile, null, "'tile' property nullified");
|
||||
t.eq(layer.ratio, null, "'ratio' property nullified");
|
||||
t.eq(layer.featureClass, null, "'featureClass' property nullified");
|
||||
t.eq(layer.format, null, "'format' property nullified");
|
||||
t.eq(layer.formatObject, null, "'formatObject' property nullified");
|
||||
t.eq(layer.formatOptions, null, "'formatOptions' property nullified");
|
||||
t.eq(layer.encodeBBOX, null, "'encodeBBOX' property nullified");
|
||||
t.eq(layer.extractAttributes, null, "'extractAttributes' property nullified");
|
||||
|
||||
layer.vectorMode = false;
|
||||
|
||||
//this call will *not* set off two tests (tile and format object are null)
|
||||
g_VectorDestroyed = null;
|
||||
g_MarkersDestroyed = null;
|
||||
OpenLayers.Layer.WFS.prototype.destroy.apply(layer, []);
|
||||
t.ok(!g_VectorDestroyed && g_MarkersDestroyed, "when vector mode is set to false, the default markers layer's destroy() method is called");
|
||||
|
||||
OpenLayers.Layer.Vector.prototype.destroy = tVectorDestroy;
|
||||
OpenLayers.Layer.Markers.prototype.destroy = tMarkersDestroy;
|
||||
}
|
||||
|
||||
function test_Layer_WFS_mapresizevector(t) {
|
||||
t.plan(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user