#904 - handlers deactivate themselves on destroy
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3901 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -214,8 +214,10 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
* Deconstruct the handler.
|
||||
*/
|
||||
destroy: function () {
|
||||
// unregister event listeners
|
||||
this.deactivate();
|
||||
// eliminate circular references
|
||||
this.control = this.map = null;
|
||||
this.control = this.map = null;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Handler"
|
||||
@@ -245,3 +247,4 @@ OpenLayers.Handler.MOD_CTRL = 2;
|
||||
*/
|
||||
OpenLayers.Handler.MOD_ALT = 4;
|
||||
|
||||
|
||||
|
||||
@@ -104,11 +104,15 @@
|
||||
}
|
||||
|
||||
function test_Handler_destroy(t) {
|
||||
t.plan(4);
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
var handler = new OpenLayers.Handler(control);
|
||||
var deactivated = false;
|
||||
handler.deactivate = function() {
|
||||
deactivated = true;
|
||||
};
|
||||
t.ok(handler.control,
|
||||
"handler has a control prior to destroy");
|
||||
t.ok(handler.map,
|
||||
@@ -118,6 +122,8 @@
|
||||
"hanlder.control is null after destroy");
|
||||
t.eq(handler.map, null,
|
||||
"handler.map is null after destroy");
|
||||
t.ok(deactivated,
|
||||
"handler.deactivate is called by destroy");
|
||||
}
|
||||
|
||||
function test_Handler_checkModifiers(t) {
|
||||
|
||||
Reference in New Issue
Block a user