Merge pull request #10024 from ahocevar/focus-condition-target

Allow EventTarget to use a different default target
This commit is contained in:
Andreas Hocevar
2019-09-26 19:59:27 +02:00
committed by GitHub
3 changed files with 22 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ class MapBrowserEventHandler extends EventTarget {
*/
constructor(map, moveTolerance) {
super();
super(map);
/**
* This is the element that we will listen to the real events on.

View File

@@ -28,10 +28,20 @@ import {clear} from '../obj.js';
* returns false.
*/
class Target extends Disposable {
constructor() {
/**
* @param {*=} opt_target Default event target for dispatched events.
*/
constructor(opt_target) {
super();
/**
* @private
* @type {*}
*/
this.target_ = opt_target;
/**
* @private
* @type {!Object<string, number>}
@@ -86,7 +96,7 @@ class Target extends Disposable {
const evt = typeof event === 'string' ? new Event(event) : event;
const type = evt.type;
if (!evt.target) {
evt.target = this;
evt.target = this.target_ || this;
}
const listeners = this.listeners_[type];
let propagate;