Use extends and super for control/MousePosition

This commit is contained in:
ahocevar
2018-07-17 14:28:10 +02:00
parent b9f08c6a2a
commit 353a00af89

View File

@@ -1,8 +1,6 @@
/** /**
* @module ol/control/MousePosition * @module ol/control/MousePosition
*/ */
import {inherits} from '../util.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {getChangeEventType} from '../Object.js'; import {getChangeEventType} from '../Object.js';
@@ -47,12 +45,11 @@ const COORDINATE_FORMAT = 'coordinateFormat';
* can be changed by using the css selector `.ol-mouse-position`. * can be changed by using the css selector `.ol-mouse-position`.
* *
* @constructor * @constructor
* @extends {module:ol/control/Control}
* @param {module:ol/control/MousePosition~Options=} opt_options Mouse position * @param {module:ol/control/MousePosition~Options=} opt_options Mouse position
* options. * options.
* @api * @api
*/ */
class MousePosition { class MousePosition extends Control {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
@@ -60,7 +57,7 @@ class MousePosition {
const element = document.createElement('DIV'); const element = document.createElement('DIV');
element.className = options.className !== undefined ? options.className : 'ol-mouse-position'; element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
Control.call(this, { super({
element: element, element: element,
render: options.render || render, render: options.render || render,
target: options.target target: options.target
@@ -173,7 +170,7 @@ class MousePosition {
* @api * @api
*/ */
setMap(map) { setMap(map) {
Control.prototype.setMap.call(this, map); super.setMap(map);
if (map) { if (map) {
const viewport = map.getViewport(); const viewport = map.getViewport();
this.listenerKeys.push( this.listenerKeys.push(
@@ -244,8 +241,6 @@ class MousePosition {
} }
} }
inherits(MousePosition, Control);
/** /**
* Update the mouseposition element. * Update the mouseposition element.