From 617dd9f0317ef38bdd4189dddcfc8133ad11deb8 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 8 Apr 2019 13:16:11 +0200 Subject: [PATCH] Remove opt_this param in ol/structs/RBush --- src/ol/source/Vector.js | 2 +- src/ol/structs/RBush.js | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index b4c26b076f..e44191b9fa 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -485,7 +485,7 @@ class VectorSource extends Source { } } else { if (this.featuresRtree_) { - this.featuresRtree_.forEach(this.removeFeatureInternal, this); + this.featuresRtree_.forEach(this.removeFeatureInternal.bind(this)); for (const id in this.nullGeometryFeatures_) { this.removeFeatureInternal(this.nullGeometryFeatures_[id]); } diff --git a/src/ol/structs/RBush.js b/src/ol/structs/RBush.js index 8d2d8fa6f1..4c0ae6c41b 100644 --- a/src/ol/structs/RBush.js +++ b/src/ol/structs/RBush.js @@ -156,41 +156,35 @@ class RBush { * Calls a callback function with each value in the tree. * If the callback returns a truthy value, this value is returned without * checking the rest of the tree. - * @param {function(this: S, T): *} callback Callback. - * @param {S=} opt_this The object to use as `this` in `callback`. + * @param {function(T): *} callback Callback. * @return {*} Callback return value. - * @template S */ - forEach(callback, opt_this) { - return this.forEach_(this.getAll(), callback, opt_this); + forEach(callback) { + return this.forEach_(this.getAll(), callback); } /** * Calls a callback function with each value in the provided extent. * @param {import("../extent.js").Extent} extent Extent. - * @param {function(this: S, T): *} callback Callback. - * @param {S=} opt_this The object to use as `this` in `callback`. + * @param {function(T): *} callback Callback. * @return {*} Callback return value. - * @template S */ - forEachInExtent(extent, callback, opt_this) { - return this.forEach_(this.getInExtent(extent), callback, opt_this); + forEachInExtent(extent, callback) { + return this.forEach_(this.getInExtent(extent), callback); } /** * @param {Array} values Values. - * @param {function(this: S, T): *} callback Callback. - * @param {S=} opt_this The object to use as `this` in `callback`. + * @param {function(T): *} callback Callback. * @private * @return {*} Callback return value. - * @template S */ - forEach_(values, callback, opt_this) { + forEach_(values, callback) { let result; for (let i = 0, l = values.length; i < l; i++) { - result = callback.call(opt_this, values[i]); + result = callback(values[i]); if (result) { return result; }