Skip to content

Commit 71fceb2

Browse files
authored
Add role and aria-label to attribution control. Closes one task in here (#598)
#247 (comment)
1 parent a8672bf commit 71fceb2

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Diff for: src/mapml-viewer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ export class MapViewer extends HTMLElement {
213213
this._addToHistory();
214214
// the attribution control is not optional
215215
this._attributionControl = this._map.attributionControl.setPrefix('<a href="https://www.w3.org/community/maps4html/" title="W3C Maps for HTML Community Group">Maps4HTML</a> | <a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>');
216-
216+
this._attributionControl.getContainer().setAttribute("role","group");
217+
this._attributionControl.getContainer().setAttribute("aria-label","Map data attribution");
218+
217219
this.setControls(false,false,true);
218220
this._crosshair = M.crosshair().addTo(this._map);
219221

Diff for: src/web-map.js

+2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ export class WebMap extends HTMLMapElement {
227227
this._addToHistory();
228228
// the attribution control is not optional
229229
this._attributionControl = this._map.attributionControl.setPrefix('<a href="https://www.w3.org/community/maps4html/" title="W3C Maps for HTML Community Group">Maps4HTML</a> | <a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>');
230+
this._attributionControl.getContainer().setAttribute("role","group");
231+
this._attributionControl.getContainer().setAttribute("aria-label","Map data attribution");
230232

231233
this.setControls(false,false,true);
232234
this._crosshair = M.crosshair().addTo(this._map);

Diff for: test/e2e/core/mapElement.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,10 @@ describe("Playwright Map Element Tests", () => {
8484

8585
expect(projection).toEqual("OSMTILE");
8686
});
87+
test("Ensure attribution control has role='group' aria-label='Map data attribution'", async () => {
88+
let role = await page.evaluate(`document.querySelector('map')._attributionControl.getContainer().getAttribute('role')`);
89+
expect(role).toEqual("group");
90+
let arialabel = await page.evaluate(`document.querySelector('map')._attributionControl.getContainer().getAttribute('aria-label')`);
91+
expect(arialabel).toEqual("Map data attribution");
92+
});
8793
});

Diff for: test/e2e/mapml-viewer/mapml-viewer.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ describe("Playwright mapml-viewer Element Tests", () => {
2626
afterAll(async function () {
2727
await context.close();
2828
});
29+
30+
test("Ensure attribution control has role='group' aria-label='Map data attribution'", async () => {
31+
let role = await page.evaluate(`document.querySelector('mapml-viewer')._attributionControl.getContainer().getAttribute('role')`);
32+
expect(role).toEqual("group");
33+
let arialabel = await page.evaluate(`document.querySelector('mapml-viewer')._attributionControl.getContainer().getAttribute('aria-label')`);
34+
expect(arialabel).toEqual("Map data attribution");
35+
});
36+
2937

3038
test("Initial map element extent", async () => {
3139
const extent = await page.$eval(

0 commit comments

Comments
 (0)