Skip to content

Commit

Permalink
Add role and aria-label to attribution control. Closes one task in he…
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth authored Nov 25, 2021
1 parent a8672bf commit 71fceb2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mapml-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export class MapViewer extends HTMLElement {
this._addToHistory();
// the attribution control is not optional
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>');

this._attributionControl.getContainer().setAttribute("role","group");
this._attributionControl.getContainer().setAttribute("aria-label","Map data attribution");

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

Expand Down
2 changes: 2 additions & 0 deletions src/web-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export class WebMap extends HTMLMapElement {
this._addToHistory();
// the attribution control is not optional
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>');
this._attributionControl.getContainer().setAttribute("role","group");
this._attributionControl.getContainer().setAttribute("aria-label","Map data attribution");

this.setControls(false,false,true);
this._crosshair = M.crosshair().addTo(this._map);
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/core/mapElement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,10 @@ describe("Playwright Map Element Tests", () => {

expect(projection).toEqual("OSMTILE");
});
test("Ensure attribution control has role='group' aria-label='Map data attribution'", async () => {
let role = await page.evaluate(`document.querySelector('map')._attributionControl.getContainer().getAttribute('role')`);
expect(role).toEqual("group");
let arialabel = await page.evaluate(`document.querySelector('map')._attributionControl.getContainer().getAttribute('aria-label')`);
expect(arialabel).toEqual("Map data attribution");
});
});
8 changes: 8 additions & 0 deletions test/e2e/mapml-viewer/mapml-viewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ describe("Playwright mapml-viewer Element Tests", () => {
afterAll(async function () {
await context.close();
});

test("Ensure attribution control has role='group' aria-label='Map data attribution'", async () => {
let role = await page.evaluate(`document.querySelector('mapml-viewer')._attributionControl.getContainer().getAttribute('role')`);
expect(role).toEqual("group");
let arialabel = await page.evaluate(`document.querySelector('mapml-viewer')._attributionControl.getContainer().getAttribute('aria-label')`);
expect(arialabel).toEqual("Map data attribution");
});


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

0 comments on commit 71fceb2

Please sign in to comment.