Skip to content

Commit e615bc4

Browse files
committed
fix attribution not being displayed for imported fragments (internal-992)
1 parent 5c6a0dc commit e615bc4

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/ui/control/attribution_control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class AttributionControl {
162162
this.styleId = stylesheet.id;
163163
}
164164

165-
const sourceCaches = this._map.style._sourceCaches;
165+
const sourceCaches = this._map.style._mergedSourceCaches;
166166
for (const id in sourceCaches) {
167167
const sourceCache = sourceCaches[id];
168168
if (sourceCache.used) {

test/unit/ui/control/attribution.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,45 @@ test('AttributionControl hides attributions for sources that are not currently v
265265
});
266266
});
267267

268+
test('AttributionControl shows attribution from both root style and its imports', (t) => {
269+
270+
const map = globalCreateMap(t, {
271+
attributionControl: false,
272+
accessToken: 'pk.123',
273+
style: {
274+
version: 8,
275+
imports: [{
276+
id: 'streets',
277+
url: '',
278+
data: {
279+
version: 8,
280+
sources: {
281+
'2': {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello'}
282+
},
283+
layers: [
284+
{id: '2', type: 'fill', source: '2'}
285+
]
286+
}
287+
}],
288+
sources: {
289+
'1': {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'World'}
290+
},
291+
layers: [
292+
{id: '1', type: 'fill', source: '1'}
293+
],
294+
owner: 'mapbox',
295+
id: 'test'
296+
}
297+
});
298+
const attribution = new AttributionControl();
299+
map.addControl(attribution);
300+
301+
map.on('load', () => {
302+
t.equal(attribution._innerContainer.innerHTML, 'Hello | World');
303+
t.end();
304+
});
305+
});
306+
268307
test('AttributionControl toggles attributions for sources whose visibility changes when zooming', (t) => {
269308
const map = createMap(t);
270309
const attribution = new AttributionControl();

0 commit comments

Comments
 (0)