Add hasListener check around dispatchEvent calls

This commit is contained in:
Maximilian Krög
2022-02-09 22:05:18 +01:00
parent d35d1cc8ad
commit ac0b8ff4a4
3 changed files with 20 additions and 16 deletions

View File

@@ -457,10 +457,12 @@ class VectorSource extends Source {
this.featuresRtree_.load(extents, geometryFeatures);
}
for (let i = 0, length = newFeatures.length; i < length; i++) {
this.dispatchEvent(
new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i])
);
if (this.hasListener(VectorEventType.ADDFEATURE)) {
for (let i = 0, length = newFeatures.length; i < length; i++) {
this.dispatchEvent(
new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i])
);
}
}
}