#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,6 +214,8 @@ OpenLayers.Handler = OpenLayers.Class({
|
|||||||
* Deconstruct the handler.
|
* Deconstruct the handler.
|
||||||
*/
|
*/
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
|
// unregister event listeners
|
||||||
|
this.deactivate();
|
||||||
// eliminate circular references
|
// eliminate circular references
|
||||||
this.control = this.map = null;
|
this.control = this.map = null;
|
||||||
},
|
},
|
||||||
@@ -245,3 +247,4 @@ OpenLayers.Handler.MOD_CTRL = 2;
|
|||||||
*/
|
*/
|
||||||
OpenLayers.Handler.MOD_ALT = 4;
|
OpenLayers.Handler.MOD_ALT = 4;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,11 +104,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_destroy(t) {
|
function test_Handler_destroy(t) {
|
||||||
t.plan(4);
|
t.plan(5);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler(control);
|
var handler = new OpenLayers.Handler(control);
|
||||||
|
var deactivated = false;
|
||||||
|
handler.deactivate = function() {
|
||||||
|
deactivated = true;
|
||||||
|
};
|
||||||
t.ok(handler.control,
|
t.ok(handler.control,
|
||||||
"handler has a control prior to destroy");
|
"handler has a control prior to destroy");
|
||||||
t.ok(handler.map,
|
t.ok(handler.map,
|
||||||
@@ -118,6 +122,8 @@
|
|||||||
"hanlder.control is null after destroy");
|
"hanlder.control is null after destroy");
|
||||||
t.eq(handler.map, null,
|
t.eq(handler.map, null,
|
||||||
"handler.map is null after destroy");
|
"handler.map is null after destroy");
|
||||||
|
t.ok(deactivated,
|
||||||
|
"handler.deactivate is called by destroy");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_checkModifiers(t) {
|
function test_Handler_checkModifiers(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user