diff --git a/src/style-spec/diff.js b/src/style-spec/diff.js index d9f6e100781..3a75f50b193 100644 --- a/src/style-spec/diff.js +++ b/src/style-spec/diff.js @@ -122,7 +122,7 @@ function diffSources(before, after, commands, sourcesRemoved) { if (!before.hasOwnProperty(sourceId)) { commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] }); } else if (!isEqual(before[sourceId], after[sourceId])) { - if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson') { + if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && before[sourceId].cluster === after[sourceId].cluster) { // geojson sources use setGeoJSONSourceData command to update commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] }); } else { diff --git a/test/unit/style-spec/diff.test.js b/test/unit/style-spec/diff.test.js index 1eb780459c8..41173dd4db7 100644 --- a/test/unit/style-spec/diff.test.js +++ b/test/unit/style-spec/diff.test.js @@ -141,6 +141,30 @@ t('diff', (t) => { }]} ], 'update a geojson source'); + t.deepEqual(diffStyles({ + sources: { + foo: { + type: 'geojson', + data: { type: 'FeatureCollection', features: [] } + } + } + }, { + sources: { + foo: { + type: 'geojson', + data: { type: 'FeatureCollection', features: [] }, + cluster: true + } + } + }), [ + { command: 'removeSource', args: ['foo'] }, + { command: 'addSource', args: ['foo', { + type: 'geojson', + cluster: true, + data: { type: 'FeatureCollection', features: [] } + }]} + ], 'remove and re-add a source if cluster change'); + t.deepEqual(diffStyles({}, { metadata: { 'mapbox:author': 'nobody' } }), [], 'ignore style metadata');