From 176021e1884032e7f5dd5c6feafd495d5f00692b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 11 Jan 2018 10:32:24 -0700 Subject: [PATCH] Rename _ol_Collection_ to Collection --- src/ol/Collection.js | 46 ++++++++++---------- src/ol/PluggableMap.js | 20 ++++----- src/ol/control.js | 4 +- src/ol/control/OverviewMap.js | 6 +-- src/ol/interaction.js | 4 +- src/ol/interaction/Modify.js | 4 +- src/ol/interaction/Snap.js | 6 +-- src/ol/interaction/Translate.js | 8 ++-- src/ol/layer/Group.js | 8 ++-- src/ol/source/Vector.js | 6 +-- test/spec/ol/collection.test.js | 50 +++++++++++----------- test/spec/ol/interaction/modify.test.js | 30 ++++++------- test/spec/ol/interaction/select.test.js | 4 +- test/spec/ol/interaction/snap.test.js | 16 +++---- test/spec/ol/interaction/translate.test.js | 4 +- test/spec/ol/layer/group.test.js | 12 +++--- test/spec/ol/source/vector.test.js | 6 +-- 17 files changed, 117 insertions(+), 117 deletions(-) diff --git a/src/ol/Collection.js b/src/ol/Collection.js index fb1423da1c..c39d984504 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -41,7 +41,7 @@ export var CollectionOptions; * @template T * @api */ -var _ol_Collection_ = function(opt_array, opt_options) { +var Collection = function(opt_array, opt_options) { BaseObject.call(this); @@ -69,14 +69,14 @@ var _ol_Collection_ = function(opt_array, opt_options) { }; -inherits(_ol_Collection_, BaseObject); +inherits(Collection, BaseObject); /** * Remove all elements from the collection. * @api */ -_ol_Collection_.prototype.clear = function() { +Collection.prototype.clear = function() { while (this.getLength() > 0) { this.pop(); } @@ -90,7 +90,7 @@ _ol_Collection_.prototype.clear = function() { * @return {ol.Collection.} This collection. * @api */ -_ol_Collection_.prototype.extend = function(arr) { +Collection.prototype.extend = function(arr) { var i, ii; for (i = 0, ii = arr.length; i < ii; ++i) { this.push(arr[i]); @@ -106,7 +106,7 @@ _ol_Collection_.prototype.extend = function(arr) { * index and the array). The return value is ignored. * @api */ -_ol_Collection_.prototype.forEach = function(f) { +Collection.prototype.forEach = function(f) { var array = this.array_; for (var i = 0, ii = array.length; i < ii; ++i) { f(array[i], i, array); @@ -122,7 +122,7 @@ _ol_Collection_.prototype.forEach = function(f) { * @return {!Array.} Array. * @api */ -_ol_Collection_.prototype.getArray = function() { +Collection.prototype.getArray = function() { return this.array_; }; @@ -133,7 +133,7 @@ _ol_Collection_.prototype.getArray = function() { * @return {T} Element. * @api */ -_ol_Collection_.prototype.item = function(index) { +Collection.prototype.item = function(index) { return this.array_[index]; }; @@ -144,7 +144,7 @@ _ol_Collection_.prototype.item = function(index) { * @observable * @api */ -_ol_Collection_.prototype.getLength = function() { +Collection.prototype.getLength = function() { return (/** @type {number} */ this.get(Property.LENGTH)); }; @@ -155,14 +155,14 @@ _ol_Collection_.prototype.getLength = function() { * @param {T} elem Element. * @api */ -_ol_Collection_.prototype.insertAt = function(index, elem) { +Collection.prototype.insertAt = function(index, elem) { if (this.unique_) { this.assertUnique_(elem); } this.array_.splice(index, 0, elem); this.updateLength_(); this.dispatchEvent( - new _ol_Collection_.Event(CollectionEventType.ADD, elem)); + new Collection.Event(CollectionEventType.ADD, elem)); }; @@ -172,7 +172,7 @@ _ol_Collection_.prototype.insertAt = function(index, elem) { * @return {T|undefined} Element. * @api */ -_ol_Collection_.prototype.pop = function() { +Collection.prototype.pop = function() { return this.removeAt(this.getLength() - 1); }; @@ -183,7 +183,7 @@ _ol_Collection_.prototype.pop = function() { * @return {number} New length of the collection. * @api */ -_ol_Collection_.prototype.push = function(elem) { +Collection.prototype.push = function(elem) { if (this.unique_) { this.assertUnique_(elem); } @@ -199,7 +199,7 @@ _ol_Collection_.prototype.push = function(elem) { * @return {T|undefined} The removed element or undefined if none found. * @api */ -_ol_Collection_.prototype.remove = function(elem) { +Collection.prototype.remove = function(elem) { var arr = this.array_; var i, ii; for (i = 0, ii = arr.length; i < ii; ++i) { @@ -218,12 +218,12 @@ _ol_Collection_.prototype.remove = function(elem) { * @return {T|undefined} Value. * @api */ -_ol_Collection_.prototype.removeAt = function(index) { +Collection.prototype.removeAt = function(index) { var prev = this.array_[index]; this.array_.splice(index, 1); this.updateLength_(); this.dispatchEvent( - new _ol_Collection_.Event(CollectionEventType.REMOVE, prev)); + new Collection.Event(CollectionEventType.REMOVE, prev)); return prev; }; @@ -234,7 +234,7 @@ _ol_Collection_.prototype.removeAt = function(index) { * @param {T} elem Element. * @api */ -_ol_Collection_.prototype.setAt = function(index, elem) { +Collection.prototype.setAt = function(index, elem) { var n = this.getLength(); if (index < n) { if (this.unique_) { @@ -243,9 +243,9 @@ _ol_Collection_.prototype.setAt = function(index, elem) { var prev = this.array_[index]; this.array_[index] = elem; this.dispatchEvent( - new _ol_Collection_.Event(CollectionEventType.REMOVE, prev)); + new Collection.Event(CollectionEventType.REMOVE, prev)); this.dispatchEvent( - new _ol_Collection_.Event(CollectionEventType.ADD, elem)); + new Collection.Event(CollectionEventType.ADD, elem)); } else { var j; for (j = n; j < index; ++j) { @@ -259,7 +259,7 @@ _ol_Collection_.prototype.setAt = function(index, elem) { /** * @private */ -_ol_Collection_.prototype.updateLength_ = function() { +Collection.prototype.updateLength_ = function() { this.set(Property.LENGTH, this.array_.length); }; @@ -269,7 +269,7 @@ _ol_Collection_.prototype.updateLength_ = function() { * @param {T} elem Element. * @param {number=} opt_except Optional index to ignore. */ -_ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) { +Collection.prototype.assertUnique_ = function(elem, opt_except) { for (var i = 0, ii = this.array_.length; i < ii; ++i) { if (this.array_[i] === elem && i !== opt_except) { throw new AssertionError(58); @@ -288,7 +288,7 @@ _ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) { * @param {ol.CollectionEventType} type Type. * @param {*=} opt_element Element. */ -_ol_Collection_.Event = function(type, opt_element) { +Collection.Event = function(type, opt_element) { Event.call(this, type); @@ -300,6 +300,6 @@ _ol_Collection_.Event = function(type, opt_element) { this.element = opt_element; }; -inherits(_ol_Collection_.Event, Event); +inherits(Collection.Event, Event); -export default _ol_Collection_; +export default Collection; diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 70e72796ca..e0c76532ee 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -2,7 +2,7 @@ * @module ol/PluggableMap */ import {getUid, inherits} from './index.js'; -import _ol_Collection_ from './Collection.js'; +import Collection from './Collection.js'; import CollectionEventType from './CollectionEventType.js'; import MapBrowserEvent from './MapBrowserEvent.js'; import MapBrowserEventHandler from './MapBrowserEventHandler.js'; @@ -276,13 +276,13 @@ var PluggableMap = function(options) { * @type {ol.Collection.} * @protected */ - this.controls = optionsInternal.controls || new _ol_Collection_(); + this.controls = optionsInternal.controls || new Collection(); /** * @type {ol.Collection.} * @protected */ - this.interactions = optionsInternal.interactions || new _ol_Collection_(); + this.interactions = optionsInternal.interactions || new Collection(); /** * @type {ol.Collection.} @@ -1457,9 +1457,9 @@ function createOptionsInternal(options) { var controls; if (options.controls !== undefined) { if (Array.isArray(options.controls)) { - controls = new _ol_Collection_(options.controls.slice()); + controls = new Collection(options.controls.slice()); } else { - assert(options.controls instanceof _ol_Collection_, + assert(options.controls instanceof Collection, 47); // Expected `controls` to be an array or an `ol.Collection` controls = options.controls; } @@ -1468,9 +1468,9 @@ function createOptionsInternal(options) { var interactions; if (options.interactions !== undefined) { if (Array.isArray(options.interactions)) { - interactions = new _ol_Collection_(options.interactions.slice()); + interactions = new Collection(options.interactions.slice()); } else { - assert(options.interactions instanceof _ol_Collection_, + assert(options.interactions instanceof Collection, 48); // Expected `interactions` to be an array or an `ol.Collection` interactions = options.interactions; } @@ -1479,14 +1479,14 @@ function createOptionsInternal(options) { var overlays; if (options.overlays !== undefined) { if (Array.isArray(options.overlays)) { - overlays = new _ol_Collection_(options.overlays.slice()); + overlays = new Collection(options.overlays.slice()); } else { - assert(options.overlays instanceof _ol_Collection_, + assert(options.overlays instanceof Collection, 49); // Expected `overlays` to be an array or an `ol.Collection` overlays = options.overlays; } } else { - overlays = new _ol_Collection_(); + overlays = new Collection(); } return { diff --git a/src/ol/control.js b/src/ol/control.js index 7184291adc..a0875894fd 100644 --- a/src/ol/control.js +++ b/src/ol/control.js @@ -1,7 +1,7 @@ /** * @module ol/control */ -import _ol_Collection_ from './Collection.js'; +import Collection from './Collection.js'; import Attribution from './control/Attribution.js'; import Rotate from './control/Rotate.js'; import Zoom from './control/Zoom.js'; @@ -23,7 +23,7 @@ export function defaults(opt_options) { var options = opt_options ? opt_options : {}; - var controls = new _ol_Collection_(); + var controls = new Collection(); var zoomControl = options.zoom !== undefined ? options.zoom : true; if (zoomControl) { diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 74a562d114..dd8d4a441c 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -2,7 +2,7 @@ * @module ol/control/OverviewMap */ import {inherits} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import PluggableMap from '../PluggableMap.js'; import MapEventType from '../MapEventType.js'; import MapProperty from '../MapProperty.js'; @@ -116,8 +116,8 @@ var OverviewMap = function(opt_options) { * @private */ this.ovmap_ = new PluggableMap({ - controls: new _ol_Collection_(), - interactions: new _ol_Collection_(), + controls: new Collection(), + interactions: new Collection(), view: options.view }); var ovmap = this.ovmap_; diff --git a/src/ol/interaction.js b/src/ol/interaction.js index c8c135db32..6ecd3982b2 100644 --- a/src/ol/interaction.js +++ b/src/ol/interaction.js @@ -1,7 +1,7 @@ /** * @module ol/interaction */ -import _ol_Collection_ from './Collection.js'; +import Collection from './Collection.js'; import Kinetic from './Kinetic.js'; import DoubleClickZoom from './interaction/DoubleClickZoom.js'; import DragPan from './interaction/DragPan.js'; @@ -41,7 +41,7 @@ export function defaults(opt_options) { var options = opt_options ? opt_options : {}; - var interactions = new _ol_Collection_(); + var interactions = new Collection(); var kinetic = new Kinetic(-0.005, 0.05, 100); diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index e5c362d59d..821d64e8c2 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -2,7 +2,7 @@ * @module ol/interaction/Modify */ import {getUid, inherits} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; import Feature from '../Feature.js'; import MapBrowserEventType from '../MapBrowserEventType.js'; @@ -195,7 +195,7 @@ var _ol_interaction_Modify_ = function(options) { var features; if (options.source) { this.source_ = options.source; - features = new _ol_Collection_(this.source_.getFeatures()); + features = new Collection(this.source_.getFeatures()); _ol_events_.listen(this.source_, VectorEventType.ADDFEATURE, this.handleSourceAdd_, this); _ol_events_.listen(this.source_, VectorEventType.REMOVEFEATURE, diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index 2556f32ed8..8bcbb93177 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -2,7 +2,7 @@ * @module ol/interaction/Snap */ import {getUid, inherits} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; import _ol_coordinate_ from '../coordinate.js'; import _ol_events_ from '../events.js'; @@ -221,7 +221,7 @@ _ol_interaction_Snap_.prototype.handleFeatureAdd_ = function(evt) { var feature; if (evt instanceof VectorSource.Event) { feature = evt.feature; - } else if (evt instanceof _ol_Collection_.Event) { + } else if (evt instanceof Collection.Event) { feature = evt.element; } this.addFeature(/** @type {ol.Feature} */ (feature)); @@ -236,7 +236,7 @@ _ol_interaction_Snap_.prototype.handleFeatureRemove_ = function(evt) { var feature; if (evt instanceof VectorSource.Event) { feature = evt.feature; - } else if (evt instanceof _ol_Collection_.Event) { + } else if (evt instanceof Collection.Event) { feature = evt.element; } this.removeFeature(/** @type {ol.Feature} */ (feature)); diff --git a/src/ol/interaction/Translate.js b/src/ol/interaction/Translate.js index 146c256abc..58d2ff34e6 100644 --- a/src/ol/interaction/Translate.js +++ b/src/ol/interaction/Translate.js @@ -2,7 +2,7 @@ * @module ol/interaction/Translate */ import {inherits} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import BaseObject from '../Object.js'; import _ol_events_ from '../events.js'; import Event from '../events/Event.js'; @@ -100,7 +100,7 @@ _ol_interaction_Translate_.handleDownEvent_ = function(event) { this.lastCoordinate_ = event.coordinate; _ol_interaction_Translate_.handleMoveEvent_.call(this, event); - var features = this.features_ || new _ol_Collection_([this.lastFeature_]); + var features = this.features_ || new Collection([this.lastFeature_]); this.dispatchEvent( new _ol_interaction_Translate_.Event( @@ -123,7 +123,7 @@ _ol_interaction_Translate_.handleUpEvent_ = function(event) { this.lastCoordinate_ = null; _ol_interaction_Translate_.handleMoveEvent_.call(this, event); - var features = this.features_ || new _ol_Collection_([this.lastFeature_]); + var features = this.features_ || new Collection([this.lastFeature_]); this.dispatchEvent( new _ol_interaction_Translate_.Event( @@ -146,7 +146,7 @@ _ol_interaction_Translate_.handleDragEvent_ = function(event) { var deltaX = newCoordinate[0] - this.lastCoordinate_[0]; var deltaY = newCoordinate[1] - this.lastCoordinate_[1]; - var features = this.features_ || new _ol_Collection_([this.lastFeature_]); + var features = this.features_ || new Collection([this.lastFeature_]); features.forEach(function(feature) { var geom = feature.getGeometry(); diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index 908bb5b7f8..a977c49a20 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -2,7 +2,7 @@ * @module ol/layer/Group */ import {getUid, inherits} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; import BaseObject from '../Object.js'; import ObjectEventType from '../ObjectEventType.js'; @@ -64,14 +64,14 @@ var LayerGroup = function(opt_options) { if (layers) { if (Array.isArray(layers)) { - layers = new _ol_Collection_(layers.slice(), {unique: true}); + layers = new Collection(layers.slice(), {unique: true}); } else { - assert(layers instanceof _ol_Collection_, + assert(layers instanceof Collection, 43); // Expected `layers` to be an array or an `ol.Collection` layers = layers; } } else { - layers = new _ol_Collection_(undefined, {unique: true}); + layers = new Collection(undefined, {unique: true}); } this.setLayers(layers); diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 462e832c77..e2ff2799c3 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -3,7 +3,7 @@ */ import {getUid, inherits, nullFunction} from '../index.js'; -import _ol_Collection_ from '../Collection.js'; +import Collection from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; import ObjectEventType from '../ObjectEventType.js'; import {extend} from '../array.js'; @@ -131,14 +131,14 @@ var VectorSource = function(opt_options) { this.featuresCollection_ = null; var collection, features; - if (options.features instanceof _ol_Collection_) { + if (options.features instanceof Collection) { collection = options.features; features = collection.getArray(); } else if (Array.isArray(options.features)) { features = options.features; } if (!useSpatialIndex && collection === undefined) { - collection = new _ol_Collection_(features); + collection = new Collection(features); } if (features !== undefined) { this.addFeaturesInternal(features); diff --git a/test/spec/ol/collection.test.js b/test/spec/ol/collection.test.js index 7d95628bb7..5bf7137a98 100644 --- a/test/spec/ol/collection.test.js +++ b/test/spec/ol/collection.test.js @@ -1,5 +1,5 @@ import _ol_events_ from '../../../src/ol/events.js'; -import _ol_Collection_ from '../../../src/ol/Collection.js'; +import Collection from '../../../src/ol/Collection.js'; import CollectionEventType from '../../../src/ol/CollectionEventType.js'; @@ -7,7 +7,7 @@ describe('ol.collection', function() { var collection; beforeEach(function() { - collection = new _ol_Collection_(); + collection = new Collection(); }); describe('create an empty collection', function() { @@ -21,7 +21,7 @@ describe('ol.collection', function() { describe('create a collection from an array', function() { it('creates the expected collection', function() { var array = [0, 1, 2]; - var collection = new _ol_Collection_(array); + var collection = new Collection(array); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(1); expect(collection.item(2)).to.eql(2); @@ -61,7 +61,7 @@ describe('ol.collection', function() { describe('insertAt', function() { it('inserts elements at the correct location', function() { - collection = new _ol_Collection_([0, 2]); + collection = new Collection([0, 2]); collection.insertAt(1, 1); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(1); @@ -80,7 +80,7 @@ describe('ol.collection', function() { describe('removeAt', function() { it('removes elements at the correction', function() { - var collection = new _ol_Collection_([0, 1, 2]); + var collection = new Collection([0, 1, 2]); collection.removeAt(1); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(2); @@ -110,13 +110,13 @@ describe('ol.collection', function() { describe('remove', function() { it('removes the first matching element', function() { - var collection = new _ol_Collection_([0, 1, 2]); + var collection = new Collection([0, 1, 2]); expect(collection.remove(1)).to.eql(1); expect(collection.getArray()).to.eql([0, 2]); expect(collection.getLength()).to.eql(2); }); it('fires a remove event', function() { - var collection = new _ol_Collection_([0, 1, 2]); + var collection = new Collection([0, 1, 2]); var cb = sinon.spy(); _ol_events_.listen(collection, CollectionEventType.REMOVE, cb); expect(collection.remove(1)).to.eql(1); @@ -124,13 +124,13 @@ describe('ol.collection', function() { expect(cb.lastCall.args[0].element).to.eql(1); }); it('does not remove more than one matching element', function() { - var collection = new _ol_Collection_([0, 1, 1, 2]); + var collection = new Collection([0, 1, 1, 2]); expect(collection.remove(1)).to.eql(1); expect(collection.getArray()).to.eql([0, 1, 2]); expect(collection.getLength()).to.eql(3); }); it('returns undefined if the element is not found', function() { - var collection = new _ol_Collection_([0, 1, 2]); + var collection = new Collection([0, 1, 2]); expect(collection.remove(3)).to.be(undefined); expect(collection.getArray()).to.eql([0, 1, 2]); expect(collection.getLength()).to.eql(3); @@ -139,7 +139,7 @@ describe('ol.collection', function() { describe('setAt and event', function() { it('does dispatch events', function() { - var collection = new _ol_Collection_(['a', 'b']); + var collection = new Collection(['a', 'b']); var added, removed; _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { added = e.element; @@ -156,7 +156,7 @@ describe('ol.collection', function() { describe('removeAt and event', function() { it('does dispatch events', function() { - var collection = new _ol_Collection_(['a']); + var collection = new Collection(['a']); var removed; _ol_events_.listen( collection, CollectionEventType.REMOVE, function(e) { @@ -169,7 +169,7 @@ describe('ol.collection', function() { describe('insertAt and event', function() { it('does dispatch events', function() { - var collection = new _ol_Collection_([0, 2]); + var collection = new Collection([0, 2]); var added; _ol_events_.listen( collection, CollectionEventType.ADD, function(e) { @@ -202,7 +202,7 @@ describe('ol.collection', function() { describe('change:length event', function() { var collection, cb; beforeEach(function() { - collection = new _ol_Collection_([0, 1, 2]); + collection = new Collection([0, 1, 2]); cb = sinon.spy(); _ol_events_.listen(collection, 'change:length', cb); }); @@ -231,7 +231,7 @@ describe('ol.collection', function() { describe('add event', function() { it('triggers add when pushing', function() { - var collection = new _ol_Collection_(); + var collection = new Collection(); var elem; _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { elem = e.element; @@ -244,7 +244,7 @@ describe('ol.collection', function() { describe('remove event', function() { var collection, cb1, cb2; beforeEach(function() { - collection = new _ol_Collection_([1]); + collection = new Collection([1]); cb1 = sinon.spy(); cb2 = sinon.spy(); }); @@ -275,7 +275,7 @@ describe('ol.collection', function() { expect(collection.item(1)).to.eql(2); }); it('fires events', function() { - var collection = new _ol_Collection_(); + var collection = new Collection(); var elems = []; _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { elems.push(e.element); @@ -287,25 +287,25 @@ describe('ol.collection', function() { describe('unique collection', function() { it('allows unique items in the constructor', function() { - new _ol_Collection_([{}, {}, {}], {unique: true}); + new Collection([{}, {}, {}], {unique: true}); }); it('throws if duplicate items are passed to the constructor', function() { var item = {}; var call = function() { - new _ol_Collection_([item, item], {unique: true}); + new Collection([item, item], {unique: true}); }; expect(call).to.throwException(); }); it('allows unique items to be added via push', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); unique.push({}); unique.push({}); }); it('throws if duplicate items are added via push', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); var item = {}; unique.push(item); var call = function() { @@ -315,13 +315,13 @@ describe('ol.collection', function() { }); it('allows unique items to be added via insertAt', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); unique.insertAt(0, {}); unique.insertAt(0, {}); }); it('throws if duplicate items are added via insertAt', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); var item = {}; unique.insertAt(0, item); var call = function() { @@ -331,20 +331,20 @@ describe('ol.collection', function() { }); it('allows unique items to be added via setAt', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); unique.setAt(0, {}); unique.setAt(1, {}); }); it('allows items to be reset via setAt', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); var item = {}; unique.setAt(0, item); unique.setAt(0, item); }); it('throws if duplicate items are added via setAt', function() { - var unique = new _ol_Collection_(undefined, {unique: true}); + var unique = new Collection(undefined, {unique: true}); var item = {}; unique.setAt(0, item); var call = function() { diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index eb38ad0780..60d886793c 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -1,4 +1,4 @@ -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import Feature from '../../../../src/ol/Feature.js'; import Map from '../../../../src/ol/Map.js'; import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js'; @@ -153,7 +153,7 @@ describe('ol.interaction.Modify', function() { it('adds features to the RTree', function() { var feature = new Feature( new Point([0, 0])); - var features = new _ol_Collection_([feature]); + var features = new Collection([feature]); var modify = new _ol_interaction_Modify_({ features: features }); @@ -164,7 +164,7 @@ describe('ol.interaction.Modify', function() { it('accepts feature without geometry', function() { var feature = new Feature(); - var features = new _ol_Collection_([feature]); + var features = new Collection([feature]); var modify = new _ol_interaction_Modify_({ features: features }); @@ -200,7 +200,7 @@ describe('ol.interaction.Modify', function() { var secondRevision = second.getGeometry().getRevision(); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -238,7 +238,7 @@ describe('ol.interaction.Modify', function() { var firstRevision = first.getGeometry().getRevision(); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -274,7 +274,7 @@ describe('ol.interaction.Modify', function() { var firstRevision = first.getGeometry().getRevision(); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -310,7 +310,7 @@ describe('ol.interaction.Modify', function() { var firstRevision = first.getGeometry().getRevision(); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -348,7 +348,7 @@ describe('ol.interaction.Modify', function() { features.push(lineFeature); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -387,7 +387,7 @@ describe('ol.interaction.Modify', function() { features.push(circleFeature); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -418,7 +418,7 @@ describe('ol.interaction.Modify', function() { beforeEach(function() { modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -523,7 +523,7 @@ describe('ol.interaction.Modify', function() { beforeEach(function() { modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features), + features: new Collection(features), deleteCondition: _ol_events_condition_.doubleClick }); map.addInteraction(modify); @@ -576,7 +576,7 @@ describe('ol.interaction.Modify', function() { }); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features), + features: new Collection(features), insertVertexCondition: listenerSpy }); map.addInteraction(modify); @@ -622,7 +622,7 @@ describe('ol.interaction.Modify', function() { features.push(feature); var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -658,7 +658,7 @@ describe('ol.interaction.Modify', function() { it('updates polygon segment data', function() { var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); @@ -698,7 +698,7 @@ describe('ol.interaction.Modify', function() { describe('#setActive', function() { it('removes the vertexFeature of deactivation', function() { var modify = new _ol_interaction_Modify_({ - features: new _ol_Collection_(features) + features: new Collection(features) }); map.addInteraction(modify); expect(modify.vertexFeature_).to.be(null); diff --git a/test/spec/ol/interaction/select.test.js b/test/spec/ol/interaction/select.test.js index b31a2faa71..7ae4810270 100644 --- a/test/spec/ol/interaction/select.test.js +++ b/test/spec/ol/interaction/select.test.js @@ -1,4 +1,4 @@ -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import Feature from '../../../../src/ol/Feature.js'; import Map from '../../../../src/ol/Map.js'; import MapBrowserEventType from '../../../../src/ol/MapBrowserEventType.js'; @@ -111,7 +111,7 @@ describe('ol.interaction.Select', function() { describe('user-provided collection', function() { it('uses the user-provided collection', function() { - var features = new _ol_Collection_(); + var features = new Collection(); var select = new _ol_interaction_Select_({features: features}); expect(select.getFeatures()).to.be(features); }); diff --git a/test/spec/ol/interaction/snap.test.js b/test/spec/ol/interaction/snap.test.js index f8b5b48a35..792c4b9f4a 100644 --- a/test/spec/ol/interaction/snap.test.js +++ b/test/spec/ol/interaction/snap.test.js @@ -1,4 +1,4 @@ -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import Feature from '../../../../src/ol/Feature.js'; import Map from '../../../../src/ol/Map.js'; import View from '../../../../src/ol/View.js'; @@ -58,7 +58,7 @@ describe('ol.interaction.Snap', function() { it('can handle XYZ coordinates', function() { var point = new Feature(new Point([0, 0, 123])); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([point]) + features: new Collection([point]) }); snapInteraction.setMap(map); @@ -75,7 +75,7 @@ describe('ol.interaction.Snap', function() { it('snaps to edges only', function() { var point = new Feature(new LineString([[-10, 0], [10, 0]])); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([point]), + features: new Collection([point]), pixelTolerance: 5, vertex: false }); @@ -93,7 +93,7 @@ describe('ol.interaction.Snap', function() { it('snaps to vertices only', function() { var point = new Feature(new LineString([[-10, 0], [10, 0]])); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([point]), + features: new Collection([point]), pixelTolerance: 5, edge: false }); @@ -111,7 +111,7 @@ describe('ol.interaction.Snap', function() { it('snaps to circle', function() { var circle = new Feature(new Circle([0, 0], 10)); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([circle]), + features: new Collection([circle]), pixelTolerance: 5 }); snapInteraction.setMap(map); @@ -130,7 +130,7 @@ describe('ol.interaction.Snap', function() { it('handle feature without geometry', function() { var feature = new Feature(); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([feature]), + features: new Collection([feature]), pixelTolerance: 5, edge: false }); @@ -150,7 +150,7 @@ describe('ol.interaction.Snap', function() { it('handle geometry changes', function() { var line = new Feature(new LineString([[-10, 0], [0, 0]])); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([line]), + features: new Collection([line]), pixelTolerance: 5, edge: false }); @@ -173,7 +173,7 @@ describe('ol.interaction.Snap', function() { alt_geometry: new LineString([[-10, 0], [10, 0]]) }); var snapInteraction = new _ol_interaction_Snap_({ - features: new _ol_Collection_([line]), + features: new Collection([line]), pixelTolerance: 5, edge: false }); diff --git a/test/spec/ol/interaction/translate.test.js b/test/spec/ol/interaction/translate.test.js index 4d080b44bc..0f5f8a1f91 100644 --- a/test/spec/ol/interaction/translate.test.js +++ b/test/spec/ol/interaction/translate.test.js @@ -1,4 +1,4 @@ -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import Feature from '../../../../src/ol/Feature.js'; import Map from '../../../../src/ol/Map.js'; import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js'; @@ -159,7 +159,7 @@ describe('ol.interaction.Translate', function() { beforeEach(function() { translate = new _ol_interaction_Translate_({ - features: new _ol_Collection_([features[0]]) + features: new Collection([features[0]]) }); map.addInteraction(translate); }); diff --git a/test/spec/ol/layer/group.test.js b/test/spec/ol/layer/group.test.js index 7f122094f2..987de1dee3 100644 --- a/test/spec/ol/layer/group.test.js +++ b/test/spec/ol/layer/group.test.js @@ -1,6 +1,6 @@ import {getUid} from '../../../../src/ol/index.js'; import {stableSort} from '../../../../src/ol/array.js'; -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import * as _ol_extent_ from '../../../../src/ol/extent.js'; import LayerGroup from '../../../../src/ol/layer/Group.js'; import Layer from '../../../../src/ol/layer/Layer.js'; @@ -50,7 +50,7 @@ describe('ol.layer.Group', function() { }); it('provides default empty layers collection', function() { - expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); + expect(layerGroup.getLayers()).to.be.a(Collection); expect(layerGroup.getLayers().getLength()).to.be(0); }); @@ -166,7 +166,7 @@ describe('ol.layer.Group', function() { maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); + expect(layerGroup.getLayers()).to.be.a(Collection); expect(layerGroup.getLayers().getLength()).to.be(1); expect(layerGroup.getLayers().item(0)).to.be(layer); @@ -207,7 +207,7 @@ describe('ol.layer.Group', function() { maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); + expect(layerGroup.getLayers()).to.be.a(Collection); expect(layerGroup.getLayers().getLength()).to.be(1); expect(layerGroup.getLayers().item(0)).to.be(layer); @@ -284,7 +284,7 @@ describe('ol.layer.Group', function() { describe('layers events', function() { it('listen / unlisten for layers added to the collection', function() { - var layers = new _ol_Collection_(); + var layers = new Collection(); var layerGroup = new LayerGroup({ layers: layers }); @@ -315,7 +315,7 @@ describe('ol.layer.Group', function() { projection: 'EPSG:4326' }) }); - var layers = new _ol_Collection_([layer]); + var layers = new Collection([layer]); var layerGroup = new LayerGroup(); layerGroup.setLayers(layers); diff --git a/test/spec/ol/source/vector.test.js b/test/spec/ol/source/vector.test.js index a35872cb59..822b48847e 100644 --- a/test/spec/ol/source/vector.test.js +++ b/test/spec/ol/source/vector.test.js @@ -1,5 +1,5 @@ import _ol_events_ from '../../../../src/ol/events.js'; -import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import Collection from '../../../../src/ol/Collection.js'; import Feature from '../../../../src/ol/Feature.js'; import Map from '../../../../src/ol/Map.js'; import View from '../../../../src/ol/View.js'; @@ -560,7 +560,7 @@ describe('ol.source.Vector', function() { }); it('returns a features collection', function() { - expect(source.getFeaturesCollection()).to.be.a(_ol_Collection_); + expect(source.getFeaturesCollection()).to.be.a(Collection); }); it('#forEachFeatureInExtent loops through all features', function() { @@ -622,7 +622,7 @@ describe('ol.source.Vector', function() { describe('with a collection of features plus spatial index', function() { var collection, source; beforeEach(function() { - collection = new _ol_Collection_(); + collection = new Collection(); source = new VectorSource({ features: collection });