Merge pull request #10024 from ahocevar/focus-condition-target
Allow EventTarget to use a different default target
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user