Skip to content

Commit a2fcb8e

Browse files
mournerstepankuzmin
authored andcommitted
fix attribution not being displayed for imported fragments (internal-992)
1 parent 118e87d commit a2fcb8e

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
@@ -163,7 +163,7 @@ class AttributionControl {
163163
this.styleId = stylesheet.id;
164164
}
165165

166-
const sourceCaches = this._map.style._sourceCaches;
166+
const sourceCaches = this._map.style._mergedSourceCaches;
167167
for (const id in sourceCaches) {
168168
const sourceCache = sourceCaches[id];
169169
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)