Merge pull request #7614 from KlausBenndorf/publicThisArgs

Remove opt_this from the API
This commit is contained in:
Tim Schaub
2017-12-19 09:30:54 -08:00
committed by GitHub
18 changed files with 72 additions and 135 deletions

View File

@@ -124,28 +124,26 @@ _ol_source_TileUTFGrid_.prototype.getTemplate = function() {
* in case of an error).
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {function(this: T, *)} callback Callback.
* @param {T=} opt_this The object to use as `this` in the callback.
* @param {function(*)} callback Callback.
* @param {boolean=} opt_request If `true` the callback is always async.
* The tile data is requested if not yet loaded.
* @template T
* @api
*/
_ol_source_TileUTFGrid_.prototype.forDataAtCoordinateAndResolution = function(
coordinate, resolution, callback, opt_this, opt_request) {
coordinate, resolution, callback, opt_request) {
if (this.tileGrid) {
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
var tile = /** @type {!ol.source.TileUTFGrid.Tile_} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
tile.forDataAtCoordinate(coordinate, callback, opt_this, opt_request);
tile.forDataAtCoordinate(coordinate, callback, null, opt_request);
} else {
if (opt_request === true) {
setTimeout(function() {
callback.call(opt_this, null);
callback(null);
}, 0);
} else {
callback.call(opt_this, null);
callback(null);
}
}
};

View File

@@ -379,18 +379,17 @@ _ol_source_Vector_.prototype.clear = function(opt_fast) {
* with each one. If the callback returns any "truthy" value, iteration will
* stop and the function will return the same value.
*
* @param {function(this: T, ol.Feature): S} callback Called with each feature
* @param {function(ol.Feature): T} callback Called with each feature
* on the source. Return a truthy value to stop iteration.
* @param {T=} opt_this The object to use as `this` in the callback.
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
* @return {T|undefined} The return value from the last call to the callback.
* @template T
* @api
*/
_ol_source_Vector_.prototype.forEachFeature = function(callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeature = function(callback) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEach(callback, opt_this);
return this.featuresRtree_.forEach(callback);
} else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this);
return this.featuresCollection_.forEach(callback);
}
};
@@ -402,18 +401,17 @@ _ol_source_Vector_.prototype.forEachFeature = function(callback, opt_this) {
* value.
*
* @param {ol.Coordinate} coordinate Coordinate.
* @param {function(this: T, ol.Feature): S} callback Called with each feature
* @param {function(ol.Feature): T} callback Called with each feature
* whose goemetry contains the provided coordinate.
* @param {T=} opt_this The object to use as `this` in the callback.
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
_ol_source_Vector_.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) {
var geometry = feature.getGeometry();
if (geometry.intersectsCoordinate(coordinate)) {
return callback.call(opt_this, feature);
return callback(feature);
} else {
return undefined;
}
@@ -435,18 +433,17 @@ _ol_source_Vector_.prototype.forEachFeatureAtCoordinateDirect = function(coordin
* features, equivalent to {@link ol.source.Vector#forEachFeature}.
*
* @param {ol.Extent} extent Extent.
* @param {function(this: T, ol.Feature): S} callback Called with each feature
* @param {function(ol.Feature): T} callback Called with each feature
* whose bounding box intersects the provided extent.
* @param {T=} opt_this The object to use as `this` in the callback.
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
* @return {T|undefined} The return value from the last call to the callback.
* @template T
* @api
*/
_ol_source_Vector_.prototype.forEachFeatureInExtent = function(extent, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureInExtent = function(extent, callback) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEachInExtent(extent, callback, opt_this);
return this.featuresRtree_.forEachInExtent(extent, callback);
} else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this);
return this.featuresCollection_.forEach(callback);
}
};
@@ -461,24 +458,23 @@ _ol_source_Vector_.prototype.forEachFeatureInExtent = function(extent, callback,
* source.forEachFeatureInExtent()} method instead.
*
* @param {ol.Extent} extent Extent.
* @param {function(this: T, ol.Feature): S} callback Called with each feature
* @param {function(ol.Feature): T} callback Called with each feature
* whose geometry intersects the provided extent.
* @param {T=} opt_this The object to use as `this` in the callback.
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
* @return {T|undefined} The return value from the last call to the callback.
* @template T
* @api
*/
_ol_source_Vector_.prototype.forEachFeatureIntersectingExtent = function(extent, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureIntersectingExtent = function(extent, callback) {
return this.forEachFeatureInExtent(extent,
/**
* @param {ol.Feature} feature Feature.
* @return {S|undefined} The return value from the last call to the callback.
* @template S
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
function(feature) {
var geometry = feature.getGeometry();
if (geometry.intersectsExtent(extent)) {
var result = callback.call(opt_this, feature);
var result = callback(feature);
if (result) {
return result;
}