Add test for new removeFeature behavior
This commit is contained in:
@@ -544,10 +544,10 @@ class VectorSource extends Source {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.featuresRtree_) {
|
if (this.featuresRtree_) {
|
||||||
// use Array forEach to ignore return
|
const removeAndIgnoreReturn = function (feature) {
|
||||||
this.featuresRtree_
|
this.removeFeatureInternal(feature);
|
||||||
.getAll()
|
}.bind(this);
|
||||||
.forEach(this.removeFeatureInternal.bind(this));
|
this.featuresRtree_.forEach(removeAndIgnoreReturn);
|
||||||
for (const id in this.nullGeometryFeatures_) {
|
for (const id in this.nullGeometryFeatures_) {
|
||||||
this.removeFeatureInternal(this.nullGeometryFeatures_[id]);
|
this.removeFeatureInternal(this.nullGeometryFeatures_[id]);
|
||||||
}
|
}
|
||||||
@@ -1037,9 +1037,6 @@ class VectorSource extends Source {
|
|||||||
if (result) {
|
if (result) {
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
// TODO at full version for consistency with other remove methods
|
|
||||||
// (would be breaking change if used as callback in forEachFeatureAtPixel)
|
|
||||||
//return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -339,6 +339,19 @@ describe('ol.source.Vector', function () {
|
|||||||
vectorSource.removeFeature(features[0]);
|
vectorSource.removeFeature(features[0]);
|
||||||
expect(listener.called).to.be(true);
|
expect(listener.called).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('accepts features that are not in the source', function () {
|
||||||
|
const changeListener = sinon.spy();
|
||||||
|
listen(vectorSource, 'change', changeListener);
|
||||||
|
|
||||||
|
const removeFeatureListener = sinon.spy();
|
||||||
|
listen(vectorSource, 'removefeature', removeFeatureListener);
|
||||||
|
|
||||||
|
const feature = new Feature(new Point([0, 0]));
|
||||||
|
vectorSource.removeFeature(feature);
|
||||||
|
expect(changeListener.called).to.be(false);
|
||||||
|
expect(removeFeatureListener.called).to.be(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("modifying a feature's geometry", function () {
|
describe("modifying a feature's geometry", function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user