Skip to content

Commit

Permalink
fix attribution not being displayed for imported fragments (internal-…
Browse files Browse the repository at this point in the history
…992)
  • Loading branch information
mourner committed Jan 25, 2024
1 parent 5c6a0dc commit e615bc4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/control/attribution_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
39 changes: 39 additions & 0 deletions test/unit/ui/control/attribution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e615bc4

Please sign in to comment.