Use extends and super for Collection

This commit is contained in:
ahocevar
2018-07-17 11:46:19 +02:00
parent 0224e2b3c5
commit aa7b6350ec
+4 -12
View File
@@ -1,7 +1,6 @@
/** /**
* @module ol/Collection * @module ol/Collection
*/ */
import {inherits} from './util.js';
import AssertionError from './AssertionError.js'; import AssertionError from './AssertionError.js';
import CollectionEventType from './CollectionEventType.js'; import CollectionEventType from './CollectionEventType.js';
import BaseObject from './Object.js'; import BaseObject from './Object.js';
@@ -21,17 +20,15 @@ const Property = {
* @classdesc * @classdesc
* Events emitted by {@link module:ol/Collection~Collection} instances are instances of this * Events emitted by {@link module:ol/Collection~Collection} instances are instances of this
* type. * type.
*
* @extends {module:ol/events/Event}
*/ */
export class CollectionEvent { export class CollectionEvent extends Event {
/** /**
* @param {module:ol/CollectionEventType} type Type. * @param {module:ol/CollectionEventType} type Type.
* @param {*=} opt_element Element. * @param {*=} opt_element Element.
*/ */
constructor(type, opt_element) { constructor(type, opt_element) {
Event.call(this, type); super(type);
/** /**
* The element that is added to or removed from the collection. * The element that is added to or removed from the collection.
@@ -44,8 +41,6 @@ export class CollectionEvent {
} }
inherits(CollectionEvent, Event);
/** /**
* @typedef {Object} Options * @typedef {Object} Options
@@ -61,10 +56,9 @@ inherits(CollectionEvent, Event);
* Collection; they trigger events on the appropriate object, not on the * Collection; they trigger events on the appropriate object, not on the
* Collection as a whole. * Collection as a whole.
* *
* @extends {module:ol/Object}
* @api * @api
*/ */
class Collection { class Collection extends BaseObject {
/** /**
* @param {Array.<T>=} opt_array Array. * @param {Array.<T>=} opt_array Array.
@@ -73,7 +67,7 @@ class Collection {
*/ */
constructor(opt_array, opt_options) { constructor(opt_array, opt_options) {
BaseObject.call(this); super();
const options = opt_options || {}; const options = opt_options || {};
@@ -288,7 +282,5 @@ class Collection {
} }
} }
inherits(Collection, BaseObject);
export default Collection; export default Collection;