Add support for EventListener Object
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener Support for native javascript eventListener.handleEvent() Typedef not correct yet.
This commit is contained in:
@@ -18,7 +18,7 @@ import {clear} from './obj.js';
|
||||
* Listener function. This function is called with an event object as argument.
|
||||
* When the function returns `false`, event propagation will stop.
|
||||
*
|
||||
* @typedef {function((Event|import("./events/Event.js").default)): (void|boolean)} ListenerFunction
|
||||
* @typedef {EventListener|function((Event|import("./events/Event.js").default)): (void|boolean)} ListenerFunction
|
||||
* @api
|
||||
*/
|
||||
|
||||
|
||||
@@ -107,6 +107,17 @@ class Target extends Disposable {
|
||||
this.pendingRemovals_[type] = 0;
|
||||
}
|
||||
++this.dispatching_[type];
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
if (listeners[i].handleEvent) {
|
||||
propagate = listeners[i].handleEvent(evt);
|
||||
} else {
|
||||
propagate = listeners[i].call(this, evt);
|
||||
}
|
||||
if (propagate === false || evt.propagationStopped) {
|
||||
propagate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
if (listeners[i].call(this, evt) === false || evt.propagationStopped) {
|
||||
propagate = false;
|
||||
|
||||
Reference in New Issue
Block a user