From fdf57d04dbfb8524fb192275f9d511997fa80998 Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Thu, 19 Dec 2024 08:38:42 +0100 Subject: [PATCH] Improves Source#updateSource to use setTiles function if available (#2355) --- src/components/source.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/source.ts b/src/components/source.ts index 38ae76e8f..53011033d 100644 --- a/src/components/source.ts +++ b/src/components/source.ts @@ -75,19 +75,10 @@ function updateSource( }); } else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') { source.setCoordinates((props as ImageSourceRaw).coordinates); - } else if ('setUrl' in source) { - // Added in 1.12.0: - // vectorTileSource.setTiles - // vectorTileSource.setUrl - switch (changedKey) { - case 'url': - source.setUrl((props as VectorSourceRaw).url); - break; - case 'tiles': - source.setTiles((props as VectorSourceRaw).tiles); - break; - default: - } + } else if ('setUrl' in source && changedKey === 'url') { + source.setUrl((props as VectorSourceRaw).url); + } else if ('setTiles' in source && changedKey === 'tiles') { + source.setTiles((props as VectorSourceRaw).tiles); } else { // eslint-disable-next-line console.warn(`Unable to update prop: ${changedKey}`);