diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 11643de713..f8d68998e5 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -42,6 +42,7 @@ The following methods did get the optional this (i.e. opt_this) arguments remove * Collection#forEach * geom/LineString#forEachSegment * Observable#on, #once, #un +* source/TileUTFGrid#forDataAtCoordinateAndResolution ### v4.6.0 diff --git a/src/ol/source/TileUTFGrid.js b/src/ol/source/TileUTFGrid.js index 6a20f53155..520f1ffbdc 100644 --- a/src/ol/source/TileUTFGrid.js +++ b/src/ol/source/TileUTFGrid.js @@ -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); } } }; diff --git a/test/spec/ol/source/tileutfgrid.test.js b/test/spec/ol/source/tileutfgrid.test.js index 84a3d9c31f..5e9055da98 100644 --- a/test/spec/ol/source/tileutfgrid.test.js +++ b/test/spec/ol/source/tileutfgrid.test.js @@ -253,18 +253,7 @@ describe('ol.source.TileUTFGrid', function() { done(); }; source.forDataAtCoordinateAndResolution( - bonn3857, resolutionZoom1, callback, null, true - ); - }); - - it('calls callback with correct `this` bound', function(done) { - var scope = {foo: 'bar'}; - var callback = function(data) { - expect(this).to.be(scope); - done(); - }; - source.forDataAtCoordinateAndResolution( - bonn3857, resolutionZoom1, callback, scope, true + bonn3857, resolutionZoom1, callback, true ); }); @@ -275,7 +264,7 @@ describe('ol.source.TileUTFGrid', function() { done(); }; source.forDataAtCoordinateAndResolution( - noState3857, resolutionZoom1, callback, null, true + noState3857, resolutionZoom1, callback, true ); });