removes opt_this from ol.Collection#forEach

this commit also removes all uses of the standard thisArg of
Array#forEach.
This commit is contained in:
simonseyock
2017-12-16 13:43:46 +01:00
parent 1aa7313a7b
commit 3e82c37bed
13 changed files with 28 additions and 36 deletions

View File

@@ -213,7 +213,7 @@ var _ol_interaction_Modify_ = function(options) {
*/
this.features_ = features;
this.features_.forEach(this.addFeature_, this);
this.features_.forEach(this.addFeature_.bind(this));
_ol_events_.listen(this.features_, CollectionEventType.ADD,
this.handleFeatureAdd_, this);
_ol_events_.listen(this.features_, CollectionEventType.REMOVE,

View File

@@ -313,12 +313,12 @@ _ol_interaction_Select_.prototype.setMap = function(map) {
var selectedFeatures =
this.featureOverlay_.getSource().getFeaturesCollection();
if (currentMap) {
selectedFeatures.forEach(currentMap.unskipFeature, currentMap);
selectedFeatures.forEach(currentMap.unskipFeature.bind(currentMap));
}
Interaction.prototype.setMap.call(this, map);
this.featureOverlay_.setMap(map);
if (map) {
selectedFeatures.forEach(map.skipFeature, map);
selectedFeatures.forEach(map.skipFeature.bind(map));
}
};

View File

@@ -302,7 +302,7 @@ _ol_interaction_Snap_.prototype.setMap = function(map) {
if (currentMap) {
keys.forEach(_ol_events_.unlistenByKey);
keys.length = 0;
features.forEach(this.forEachFeatureRemove_, this);
features.forEach(this.forEachFeatureRemove_.bind(this));
}
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
@@ -322,7 +322,7 @@ _ol_interaction_Snap_.prototype.setMap = function(map) {
this.handleFeatureRemove_, this)
);
}
features.forEach(this.forEachFeatureAdd_, this);
features.forEach(this.forEachFeatureAdd_.bind(this));
}
};
@@ -613,7 +613,7 @@ _ol_interaction_Snap_.handleEvent_ = function(evt) {
_ol_interaction_Snap_.handleUpEvent_ = function(evt) {
var featuresToUpdate = _ol_obj_.getValues(this.pendingFeatures_);
if (featuresToUpdate.length) {
featuresToUpdate.forEach(this.updateFeature_, this);
featuresToUpdate.forEach(this.updateFeature_.bind(this));
this.pendingFeatures_ = {};
}
return false;