From 434ea92c9280b0ab5928ba6bf8a05c0096db83b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dos=20Santos?= <60154937+0xOnyx@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:13:26 +0100 Subject: [PATCH] fix(options): only duplicate styles without source for hot/cold --- src/options.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/options.js b/src/options.js index 8e88928e6..67608046b 100644 --- a/src/options.js +++ b/src/options.js @@ -37,13 +37,10 @@ const hideControls = { }; function addSources(styles, sourceBucket) { - return styles.map((style) => { - if (style.source) return style; - return Object.assign({}, style, { - id: `${style.id}.${sourceBucket}`, - source: (sourceBucket === 'hot') ? Constants.sources.HOT : Constants.sources.COLD - }); - }); + return styles.map((style) => Object.assign({}, style, { + id: `${style.id}.${sourceBucket}`, + source: (sourceBucket === 'hot') ? Constants.sources.HOT : Constants.sources.COLD + })); } export default function(options = {}) { @@ -62,7 +59,11 @@ export default function(options = {}) { withDefaults = Object.assign({}, defaultOptions, withDefaults); // Layers with a shared source should be adjacent for performance reasons - withDefaults.styles = addSources(withDefaults.styles, 'cold').concat(addSources(withDefaults.styles, 'hot')); + const sourcedStyles = withDefaults.styles.filter((style) => style.source); + const unsourcedStyles = withDefaults.styles.filter((style) => !style.source); + withDefaults.styles = sourcedStyles + .concat(addSources(unsourcedStyles, 'cold')) + .concat(addSources(unsourcedStyles, 'hot')); return withDefaults; }