diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index 2de1165a83..04b90f2bdb 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -452,7 +452,9 @@ OpenLayers.Events = OpenLayers.Class({ /** * APIProperty: extensions * {Object} Event extensions registered with this instance. Keys are - * event types, values are extension instances. + * event types, values are {OpenLayers.Events.*} extension instances or + * {Boolean} for events that an instantiated extension provides in + * addition to the one it was created for. * * Extensions create an event in addition to browser events, which usually * fires when a sequence of browser events is completed. Extensions are @@ -462,9 +464,9 @@ OpenLayers.Events = OpenLayers.Class({ * Extensions are created in the namespace using * , and named after the event they provide. * The constructor receives the target instance as - * argument. Extensions should register their browser events using - * , with {extension: true} as 4th argument. See below for a - * minimal extension. + * argument. Extensions that need to capture browser events before they + * propagate can register their listeners events using , with + * {extension: true} as 4th argument. * * If an extension creates more than one event, an alias for each event * type should be created and reference the same class. The constructor @@ -480,11 +482,14 @@ OpenLayers.Events = OpenLayers.Class({ * this.target = target; * this.target.register("click", this, this.doStuff, {extension: true}); * // only required if extension provides more than one event type - * this.target.extensions["foostart"] = this; - * this.target.extensions["fooend"] = this; + * this.target.extensions["foostart"] = true; + * this.target.extensions["fooend"] = true; * }, * destroy: function() { * this.target.unregister("click", this, this.doStuff); + * // only required if extension provides more than one event type + * delete this.target.extensions["foostart"]; + * delete this.target.extensions["fooend"]; * }, * doStuff: function(evt) { * var propagate = true; @@ -565,7 +570,9 @@ OpenLayers.Events = OpenLayers.Class({ */ destroy: function () { for (var e in this.extensions) { - this.extensions[e].destroy(); + if (typeof this.extensions[e] !== "boolean") { + this.extensions[e].destroy(); + } } this.extensions = null; if (this.element) {