diff --git a/src/ui/control/attribution_control.js b/src/ui/control/attribution_control.js index 3b37106995c..c85c0dd93c8 100644 --- a/src/ui/control/attribution_control.js +++ b/src/ui/control/attribution_control.js @@ -162,7 +162,7 @@ class AttributionControl { this.styleId = stylesheet.id; } - const sourceCaches = this._map.style._sourceCaches; + const sourceCaches = this._map.style._mergedSourceCaches; for (const id in sourceCaches) { const sourceCache = sourceCaches[id]; if (sourceCache.used) { diff --git a/test/unit/ui/control/attribution.test.js b/test/unit/ui/control/attribution.test.js index cdc2ab04992..dbcf795f72f 100644 --- a/test/unit/ui/control/attribution.test.js +++ b/test/unit/ui/control/attribution.test.js @@ -265,6 +265,45 @@ test('AttributionControl hides attributions for sources that are not currently v }); }); +test('AttributionControl shows attribution from both root style and its imports', (t) => { + + const map = globalCreateMap(t, { + attributionControl: false, + accessToken: 'pk.123', + style: { + version: 8, + imports: [{ + id: 'streets', + url: '', + data: { + version: 8, + sources: { + '2': {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello'} + }, + layers: [ + {id: '2', type: 'fill', source: '2'} + ] + } + }], + sources: { + '1': {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'World'} + }, + layers: [ + {id: '1', type: 'fill', source: '1'} + ], + owner: 'mapbox', + id: 'test' + } + }); + const attribution = new AttributionControl(); + map.addControl(attribution); + + map.on('load', () => { + t.equal(attribution._innerContainer.innerHTML, 'Hello | World'); + t.end(); + }); +}); + test('AttributionControl toggles attributions for sources whose visibility changes when zooming', (t) => { const map = createMap(t); const attribution = new AttributionControl();