Remove use of goog.array.forEach
This commit is contained in:
@@ -136,7 +136,7 @@ ol.Collection.prototype.extend = function(arr) {
|
||||
* @api stable
|
||||
*/
|
||||
ol.Collection.prototype.forEach = function(f, opt_this) {
|
||||
goog.array.forEach(this.array_, f, opt_this);
|
||||
this.array_.forEach(f, opt_this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.control.Control');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.events');
|
||||
goog.require('ol.MapEventType');
|
||||
@@ -109,7 +108,7 @@ ol.control.Control.prototype.setMap = function(map) {
|
||||
goog.dom.removeNode(this.element);
|
||||
}
|
||||
if (this.listenerKeys.length > 0) {
|
||||
goog.array.forEach(this.listenerKeys, goog.events.unlistenByKey);
|
||||
this.listenerKeys.forEach(goog.events.unlistenByKey);
|
||||
this.listenerKeys.length = 0;
|
||||
}
|
||||
this.map_ = map;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.format.WMSCapabilities');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.object');
|
||||
@@ -344,7 +343,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
|
||||
// See 7.2.4.8
|
||||
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
|
||||
goog.array.forEach(addKeys, function(key) {
|
||||
addKeys.forEach(function(key) {
|
||||
if (key in parentLayerObject) {
|
||||
var childValue = goog.object.setIfUndefined(layerObject, key, []);
|
||||
childValue = childValue.concat(parentLayerObject[key]);
|
||||
@@ -354,7 +353,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
|
||||
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
|
||||
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
|
||||
goog.array.forEach(replaceKeys, function(key) {
|
||||
replaceKeys.forEach(function(key) {
|
||||
if (!(key in layerObject)) {
|
||||
var parentValue = parentLayerObject[key];
|
||||
layerObject[key] = parentValue;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.Image');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
@@ -151,6 +150,6 @@ ol.Image.prototype.load = function() {
|
||||
ol.Image.prototype.unlistenImage_ = function() {
|
||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_),
|
||||
'this.imageListenerKeys_ should not be null');
|
||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.ImageTile');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
@@ -163,6 +162,6 @@ ol.ImageTile.prototype.load = function() {
|
||||
ol.ImageTile.prototype.unlistenImage_ = function() {
|
||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_),
|
||||
'this.imageListenerKeys_ should not be null');
|
||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.interaction.Snap');
|
||||
goog.provide('ol.interaction.SnapProperty');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
@@ -321,7 +320,7 @@ ol.interaction.Snap.prototype.setMap = function(map) {
|
||||
var features = this.getFeatures_();
|
||||
|
||||
if (currentMap) {
|
||||
goog.array.forEach(keys, ol.Observable.unByKey);
|
||||
keys.forEach(ol.Observable.unByKey);
|
||||
keys.length = 0;
|
||||
features.forEach(this.forEachFeatureRemove_, this);
|
||||
}
|
||||
@@ -600,7 +599,7 @@ ol.interaction.Snap.handleEvent_ = function(evt) {
|
||||
ol.interaction.Snap.handleUpEvent_ = function(evt) {
|
||||
var featuresToUpdate = goog.object.getValues(this.pendingFeatures_);
|
||||
if (featuresToUpdate.length) {
|
||||
goog.array.forEach(featuresToUpdate, this.updateFeature_, this);
|
||||
featuresToUpdate.forEach(this.updateFeature_, this);
|
||||
this.pendingFeatures_ = {};
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.layer.Group');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
@@ -95,7 +94,7 @@ ol.layer.Group.prototype.handleLayerChange_ = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
||||
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
|
||||
this.layersListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.layersListenerKeys_.length = 0;
|
||||
|
||||
var layers = this.getLayers();
|
||||
@@ -106,7 +105,7 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
||||
this.handleLayersRemove_, false, this));
|
||||
|
||||
goog.object.forEach(this.listenerKeys_, function(keys) {
|
||||
goog.array.forEach(keys, goog.events.unlistenByKey);
|
||||
keys.forEach(goog.events.unlistenByKey);
|
||||
});
|
||||
goog.object.clear(this.listenerKeys_);
|
||||
|
||||
@@ -153,7 +152,7 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
|
||||
var key = goog.getUid(layer).toString();
|
||||
goog.asserts.assert(key in this.listenerKeys_, 'no listeners to unregister');
|
||||
goog.array.forEach(this.listenerKeys_[key], goog.events.unlistenByKey);
|
||||
this.listenerKeys_[key].forEach(goog.events.unlistenByKey);
|
||||
delete this.listenerKeys_[key];
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -1119,8 +1119,7 @@ ol.Map.prototype.handleLayerGroupPropertyChanged_ = function(event) {
|
||||
*/
|
||||
ol.Map.prototype.handleLayerGroupChanged_ = function() {
|
||||
if (!goog.isNull(this.layerGroupPropertyListenerKeys_)) {
|
||||
goog.array.forEach(this.layerGroupPropertyListenerKeys_,
|
||||
goog.events.unlistenByKey);
|
||||
this.layerGroupPropertyListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.layerGroupPropertyListenerKeys_ = null;
|
||||
}
|
||||
var layerGroup = this.getLayerGroup();
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.MapBrowserEvent.EventType');
|
||||
goog.provide('ol.MapBrowserEventHandler');
|
||||
goog.provide('ol.MapBrowserPointerEvent');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.BrowserEvent');
|
||||
@@ -293,7 +292,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
|
||||
goog.asserts.assert(this.activePointers_ >= 0,
|
||||
'this.activePointers_ should be equal to or larger than 0');
|
||||
if (this.activePointers_ === 0) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
this.dragging_ = false;
|
||||
this.down_ = null;
|
||||
@@ -427,7 +426,7 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
|
||||
this.pointerdownListenerKey_ = null;
|
||||
}
|
||||
if (!goog.isNull(this.dragListenerKeys_)) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
}
|
||||
if (!goog.isNull(this.documentPointerEventHandler_)) {
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
goog.provide('ol.pointer.PointerEventHandler');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.BrowserEvent');
|
||||
@@ -119,7 +118,7 @@ ol.pointer.PointerEventHandler.prototype.registerSource =
|
||||
var newEvents = s.getEvents();
|
||||
|
||||
if (newEvents) {
|
||||
goog.array.forEach(newEvents, function(e) {
|
||||
newEvents.forEach(function(e) {
|
||||
var handler = s.getHandlerForEvent(e);
|
||||
|
||||
if (handler) {
|
||||
@@ -179,7 +178,7 @@ ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
|
||||
* @param {Array.<string>} events List of events.
|
||||
*/
|
||||
ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
|
||||
goog.array.forEach(events, function(eventName) {
|
||||
events.forEach(function(eventName) {
|
||||
goog.events.listen(this.element_, eventName,
|
||||
this.eventHandler_, false, this);
|
||||
}, this);
|
||||
@@ -192,7 +191,7 @@ ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
|
||||
* @param {Array.<string>} events List of events.
|
||||
*/
|
||||
ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) {
|
||||
goog.array.forEach(events, function(e) {
|
||||
events.forEach(function(e) {
|
||||
goog.events.unlisten(this.element_, e,
|
||||
this.eventHandler_, false, this);
|
||||
}, this);
|
||||
|
||||
@@ -4,7 +4,6 @@ goog.provide('ol.proj.Projection');
|
||||
goog.provide('ol.proj.ProjectionLike');
|
||||
goog.provide('ol.proj.Units');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol');
|
||||
@@ -412,8 +411,8 @@ ol.proj.transforms_ = {};
|
||||
*/
|
||||
ol.proj.addEquivalentProjections = function(projections) {
|
||||
ol.proj.addProjections(projections);
|
||||
goog.array.forEach(projections, function(source) {
|
||||
goog.array.forEach(projections, function(destination) {
|
||||
projections.forEach(function(source) {
|
||||
projections.forEach(function(destination) {
|
||||
if (source !== destination) {
|
||||
ol.proj.addTransform(source, destination, ol.proj.cloneTransform);
|
||||
}
|
||||
@@ -437,8 +436,8 @@ ol.proj.addEquivalentProjections = function(projections) {
|
||||
*/
|
||||
ol.proj.addEquivalentTransforms =
|
||||
function(projections1, projections2, forwardTransform, inverseTransform) {
|
||||
goog.array.forEach(projections1, function(projection1) {
|
||||
goog.array.forEach(projections2, function(projection2) {
|
||||
projections1.forEach(function(projection1) {
|
||||
projections2.forEach(function(projection2) {
|
||||
ol.proj.addTransform(projection1, projection2, forwardTransform);
|
||||
ol.proj.addTransform(projection2, projection1, inverseTransform);
|
||||
});
|
||||
@@ -464,7 +463,7 @@ ol.proj.addProjection = function(projection) {
|
||||
*/
|
||||
ol.proj.addProjections = function(projections) {
|
||||
var addedProjections = [];
|
||||
goog.array.forEach(projections, function(projection) {
|
||||
projections.forEach(function(projection) {
|
||||
addedProjections.push(ol.proj.addProjection(projection));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -301,7 +301,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
||||
features.push(feature);
|
||||
}, this);
|
||||
goog.array.sort(features, vectorLayerRenderOrder);
|
||||
goog.array.forEach(features, renderFeature, this);
|
||||
features.forEach(renderFeature, this);
|
||||
} else {
|
||||
vectorSource.forEachFeatureInExtentAtResolution(
|
||||
extent, resolution, renderFeature, this);
|
||||
|
||||
@@ -309,7 +309,7 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame =
|
||||
features.push(feature);
|
||||
}, this);
|
||||
goog.array.sort(features, vectorLayerRenderOrder);
|
||||
goog.array.forEach(features, renderFeature, this);
|
||||
features.forEach(renderFeature, this);
|
||||
} else {
|
||||
vectorSource.forEachFeatureInExtentAtResolution(
|
||||
extent, resolution, renderFeature, this);
|
||||
|
||||
@@ -277,7 +277,7 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
|
||||
features.push(feature);
|
||||
}, this);
|
||||
goog.array.sort(features, vectorLayerRenderOrder);
|
||||
goog.array.forEach(features, renderFeature, this);
|
||||
features.forEach(renderFeature, this);
|
||||
} else {
|
||||
vectorSource.forEachFeatureInExtentAtResolution(
|
||||
extent, resolution, renderFeature, this);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.source.BingMaps');
|
||||
|
||||
goog.require('goog.Uri');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.net.Jsonp');
|
||||
goog.require('ol.Attribution');
|
||||
@@ -150,15 +149,12 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
var html = imageryProvider.attribution;
|
||||
/** @type {Object.<string, Array.<ol.TileRange>>} */
|
||||
var tileRanges = {};
|
||||
goog.array.forEach(
|
||||
imageryProvider.coverageAreas,
|
||||
function(coverageArea) {
|
||||
imageryProvider.coverageAreas.forEach(function(coverageArea) {
|
||||
var minZ = coverageArea.zoomMin;
|
||||
var maxZ = Math.min(coverageArea.zoomMax, maxZoom);
|
||||
var bbox = coverageArea.bbox;
|
||||
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
|
||||
var extent = ol.extent.applyTransform(
|
||||
epsg4326Extent, transform);
|
||||
var extent = ol.extent.applyTransform(epsg4326Extent, transform);
|
||||
var tileRange, z, zKey;
|
||||
for (z = minZ; z <= maxZ; ++z) {
|
||||
zKey = z.toString();
|
||||
|
||||
@@ -374,7 +374,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
|
||||
if (opt_fast) {
|
||||
for (var featureId in this.featureChangeKeys_) {
|
||||
var keys = this.featureChangeKeys_[featureId];
|
||||
goog.array.forEach(keys, goog.events.unlistenByKey);
|
||||
keys.forEach(goog.events.unlistenByKey);
|
||||
}
|
||||
if (goog.isNull(this.featuresCollection_)) {
|
||||
this.featureChangeKeys_ = {};
|
||||
@@ -823,8 +823,7 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
|
||||
var featureKey = goog.getUid(feature).toString();
|
||||
goog.asserts.assert(featureKey in this.featureChangeKeys_,
|
||||
'featureKey exists in featureChangeKeys');
|
||||
goog.array.forEach(this.featureChangeKeys_[featureKey],
|
||||
goog.events.unlistenByKey);
|
||||
this.featureChangeKeys_[featureKey].forEach(goog.events.unlistenByKey);
|
||||
delete this.featureChangeKeys_[featureKey];
|
||||
var id = feature.getId();
|
||||
if (id !== undefined) {
|
||||
|
||||
@@ -402,7 +402,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
|
||||
var dimensions = {};
|
||||
if ('Dimension' in l) {
|
||||
goog.array.forEach(l['Dimension'], function(elt, index, array) {
|
||||
l['Dimension'].forEach(function(elt, index, array) {
|
||||
var key = elt['Identifier'];
|
||||
var value = elt['default'];
|
||||
if (value !== undefined) {
|
||||
@@ -467,7 +467,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
goog.string.startsWith(requestEncoding, 'REST')) {
|
||||
// Add REST tile resource url
|
||||
requestEncoding = ol.source.WMTSRequestEncoding.REST;
|
||||
goog.array.forEach(l['ResourceURL'], function(elt, index, array) {
|
||||
l['ResourceURL'].forEach(function(elt, index, array) {
|
||||
if (elt['resourceType'] == 'tile') {
|
||||
format = elt['format'];
|
||||
urls.push(/** @type {string} */ (elt['template']));
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.style.IconAnchorUnits');
|
||||
goog.provide('ol.style.IconImageCache');
|
||||
goog.provide('ol.style.IconOrigin');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventTarget');
|
||||
@@ -581,7 +580,7 @@ ol.style.IconImage_.prototype.load = function() {
|
||||
ol.style.IconImage_.prototype.unlistenImage_ = function() {
|
||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_),
|
||||
'we must have listeners registered');
|
||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
|
||||
|
||||
@@ -108,11 +108,9 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
|
||||
return b[scaleDenominatorPropName] - a[scaleDenominatorPropName];
|
||||
});
|
||||
|
||||
goog.array.forEach(matrixSet[matrixIdsPropName],
|
||||
function(elt, index, array) {
|
||||
matrixSet[matrixIdsPropName].forEach(function(elt, index, array) {
|
||||
matrixIds.push(elt[identifierPropName]);
|
||||
var resolution = elt[scaleDenominatorPropName] * 0.28E-3 /
|
||||
metersPerUnit;
|
||||
var resolution = elt[scaleDenominatorPropName] * 0.28E-3 / metersPerUnit;
|
||||
var tileWidth = elt[tileWidthPropName];
|
||||
var tileHeight = elt[tileHeightPropName];
|
||||
if (switchOriginXY) {
|
||||
|
||||
@@ -11,8 +11,8 @@ describe('ol.proj', function() {
|
||||
|
||||
function _testAllEquivalent(codes) {
|
||||
var projections = codes.map(ol.proj.get);
|
||||
goog.array.forEach(projections, function(source) {
|
||||
goog.array.forEach(projections, function(destination) {
|
||||
projections.forEach(function(source) {
|
||||
projections.forEach(function(destination) {
|
||||
expect(ol.proj.equivalent(source, destination)).to.be.ok();
|
||||
});
|
||||
});
|
||||
@@ -522,7 +522,6 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.proj.Units');
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('ol.rendering.layer.Image', function() {
|
||||
}
|
||||
};
|
||||
|
||||
goog.array.forEach(sources, function(source) {
|
||||
sources.forEach(function(source) {
|
||||
source.on('imageloadstart', function(event) {
|
||||
imagesLoading++;
|
||||
});
|
||||
@@ -84,7 +84,6 @@ describe('ol.rendering.layer.Image', function() {
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.Map');
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('ol.rendering.layer.Tile', function() {
|
||||
}
|
||||
};
|
||||
|
||||
goog.array.forEach(sources, function(source) {
|
||||
sources.forEach(function(source) {
|
||||
source.on('tileloadstart', function(event) {
|
||||
tilesLoading++;
|
||||
});
|
||||
@@ -190,7 +190,6 @@ describe('ol.rendering.layer.Tile', function() {
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.Map');
|
||||
|
||||
Reference in New Issue
Block a user