protect unregister() from someone trying to unregister an un-enabled event. total extreme case, but whatever. added test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@873 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -121,10 +121,12 @@ OpenLayers.Events.prototype = {
|
|||||||
obj = this.object;
|
obj = this.object;
|
||||||
}
|
}
|
||||||
var listeners = this.listeners[type];
|
var listeners = this.listeners[type];
|
||||||
for (var i = 0; i < listeners.length; i++) {
|
if (listeners != null) {
|
||||||
if (listeners[i].obj == obj && listeners[i].func == func) {
|
for (var i = 0; i < listeners.length; i++) {
|
||||||
listeners.splice(i, 1);
|
if (listeners[i].obj == obj && listeners[i].func == func) {
|
||||||
break;
|
listeners.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
function test_02_Events_register_unregister(t) {
|
function test_02_Events_register_unregister(t) {
|
||||||
|
|
||||||
t.plan( 14 );
|
t.plan( 15 );
|
||||||
|
|
||||||
var mapDiv = $('map');
|
var mapDiv = $('map');
|
||||||
var obj = {result: 0};
|
var obj = {result: 0};
|
||||||
@@ -105,7 +105,8 @@
|
|||||||
}
|
}
|
||||||
t.ok( (listenerList.length == 1) && !found, "unregister correctly removes callback when no obj specified" );
|
t.ok( (listenerList.length == 1) && !found, "unregister correctly removes callback when no obj specified" );
|
||||||
|
|
||||||
|
events.unregister("chicken", null, func3);
|
||||||
|
t.ok( events.listeners["chicken"] == null, "unregistering an event that is not enabled does not wierdly enable it -- or cause a script error")
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_03_Events_remove(t) {
|
function test_03_Events_remove(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user