changing functionality of Events.register(). Now if a null callback is passed in, no action is taken. If a null *obj* is passed in, however, the obj used is this.object (the Events Object's related object). Added tests to make sure this works.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@869 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
|
||||
function test_02_Events_register(t) {
|
||||
|
||||
t.plan( 6 );
|
||||
t.plan( 10 );
|
||||
|
||||
var mapDiv = $('map');
|
||||
var obj = {result: 0};
|
||||
@@ -65,6 +65,18 @@
|
||||
t.ok( listenerList[1].obj == obj, "obj property correctly registered");
|
||||
t.ok( listenerList[1].func == func2, "func property correctly registered");
|
||||
|
||||
var func3 = function () { this.result = this.result + 3; }
|
||||
events.register( "doThingA", null, func3 );
|
||||
|
||||
var listenerList = events.listeners["doThingA"];
|
||||
t.eq( listenerList.length, 3, "register correctly appends new callback to event.listeners[doThingA] even when obj passed in is null" );
|
||||
t.ok( listenerList[2].obj == obj, "obj is correctly set to Events.object default when null is passed in.");
|
||||
t.ok( listenerList[2].func == func3, "func property correctly registered");
|
||||
|
||||
events.register( "doThingA", obj, null);
|
||||
|
||||
var listenerList = events.listeners["doThingA"];
|
||||
t.eq( listenerList.length, 3, "register correctly does not append null callback to event.listeners[doThingA] even when obj passed in is null" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user