fixed functionality of unregister() function, added ability to pass null value for obj. Added tests.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@870 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-04 12:57:34 +00:00
parent 7d6f4dea78
commit abac8a5d44
2 changed files with 30 additions and 3 deletions

View File

@@ -115,9 +115,12 @@ OpenLayers.Events.prototype = {
* @param {Function} func
*/
unregister: function (type, obj, func) {
if (obj == null) {
obj = this.object;
}
var listeners = this.listeners[type];
for (var i = 0; i < listeners.length; i++) {
if (listeners[i].obj == obj && listeners[i].type == type) {
if (listeners[i].obj == obj && listeners[i].func == func) {
listeners.splice(i, 1);
break;
}