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;
|
||||
}
|
||||
var listeners = this.listeners[type];
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
if (listeners[i].obj == obj && listeners[i].func == func) {
|
||||
listeners.splice(i, 1);
|
||||
break;
|
||||
if (listeners != null) {
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
if (listeners[i].obj == obj && listeners[i].func == func) {
|
||||
listeners.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
function test_02_Events_register_unregister(t) {
|
||||
|
||||
t.plan( 14 );
|
||||
t.plan( 15 );
|
||||
|
||||
var mapDiv = $('map');
|
||||
var obj = {result: 0};
|
||||
@@ -105,7 +105,8 @@
|
||||
}
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user