diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 6b68b481db..ce4d8a2ebc 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -653,7 +653,7 @@ class VectorSource extends Source { } /** - * Get all snapshot of the features currently on the source in random order. The returned array + * Get a snapshot of the features currently on the source in random order. The returned array * is a copy, the features are references to the features in the source. * @return {Array>} Features. * @api diff --git a/test/spec/ol/source/vector.test.js b/test/spec/ol/source/vector.test.js index ad69fea674..6940d5fe6f 100644 --- a/test/spec/ol/source/vector.test.js +++ b/test/spec/ol/source/vector.test.js @@ -143,6 +143,18 @@ describe('ol.source.Vector', function () { expect(feature).to.be(features[0]); }); }); + + describe('#getFeatures', function () { + it('does not return the internal array when useSpatialIndex is false', function () { + const noSpatialIndexSource = new VectorSource({ + useSpatialIndex: false, + features: vectorSource.getFeatures(), + }); + expect(noSpatialIndexSource.getFeatures()).to.not.be( + noSpatialIndexSource.getFeaturesCollection().getArray() + ); + }); + }); }); describe('clear and refresh', function () {