Skip to content

Commit

Permalink
fix(has-no-more-than-one-main): Rename check to page-no-duplicate for…
Browse files Browse the repository at this point in the history
… better reuse
  • Loading branch information
WilcoFiers committed Mar 6, 2018
1 parent ced7f2f commit e75324b
Show file tree
Hide file tree
Showing 33 changed files with 201 additions and 274 deletions.
4 changes: 2 additions & 2 deletions doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
| label-title-only | Ensures that every form element is not solely labeled using the title or aria-describedby attributes | cat.forms, best-practice | true |
| label | Ensures every form element has a label | cat.forms, wcag2a, wcag332, wcag131, section508, section508.22.n | true |
| landmark-main-is-top-level | The main landmark should not be contained in another landmark | best-practice | true |
| landmark-no-more-than-one-banner | A banner landmark identifies site-oriented content at the beginning of each page within a website | best-practice | true |
| landmark-no-more-than-one-contentinfo | A contentinfo landmark is a way to identify common information at the bottom of each page within a website | best-practice | true |
| landmark-no-duplicate-banner | Ensures the document has no more than one banner landmark | best-practice | true |
| landmark-no-duplicate-contentinfo | Ensures the document has no more than one contentinfo landmark | best-practice | true |
| landmark-one-main | Ensures a navigation point to the primary content of the page. If the page contains iframes, each iframe should contain either no main landmarks or just one. | best-practice | true |
| layout-table | Ensures presentational <table> elements do not use <th>, <caption> elements or the summary attribute | cat.semantics, wcag2a, wcag131 | true |
| link-in-text-block | Links can be distinguished without relying on color | cat.color, experimental, wcag2a, wcag141 | true |
Expand Down
29 changes: 0 additions & 29 deletions lib/checks/keyboard/has-no-more-than-one-banner.js

This file was deleted.

11 changes: 0 additions & 11 deletions lib/checks/keyboard/has-no-more-than-one-banner.json

This file was deleted.

29 changes: 0 additions & 29 deletions lib/checks/keyboard/has-no-more-than-one-contentinfo.js

This file was deleted.

11 changes: 0 additions & 11 deletions lib/checks/keyboard/has-no-more-than-one-contentinfo.json

This file was deleted.

2 changes: 0 additions & 2 deletions lib/checks/keyboard/has-no-more-than-one-main.js

This file was deleted.

15 changes: 15 additions & 0 deletions lib/checks/keyboard/page-no-duplicate-banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "page-no-duplicate-banner",
"evaluate": "page-no-duplicate.js",
"options": {
"selector": "header:not([role]), [role=banner]",
"nativeScopeFilter": "article, aside, main, nav, section"
},
"metadata": {
"impact": "moderate",
"messages": {
"pass": "Document has no more than one banner landmark",
"fail": "Document has more than one banner landmark"
}
}
}
15 changes: 15 additions & 0 deletions lib/checks/keyboard/page-no-duplicate-contentinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "page-no-duplicate-contentinfo",
"evaluate": "page-no-duplicate.js",
"options": {
"selector": "footer:not([role]), [role=contentinfo]",
"nativeScopeFilter": "article, aside, main, nav, section"
},
"metadata": {
"impact": "moderate",
"messages": {
"pass": "Document has no more than one contentinfo landmark",
"fail": "Document has more than one contentinfo landmark"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"id": "has-no-more-than-one-main",
"evaluate": "has-no-more-than-one-main.js",
"id": "page-no-duplicate-main",
"evaluate": "page-no-duplicate.js",
"options": {
"selector": "main:not([role]), [role='main']"
},
"metadata": {
"impact": "moderate",
"messages": {
Expand Down
18 changes: 18 additions & 0 deletions lib/checks/keyboard/page-no-duplicate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if (!options || !options.selector || typeof options.selector !== 'string') {
throw new TypeError('visible-in-page requires options.selector to be a string');
}

let elms = axe.utils.querySelectorAll(virtualNode, options.selector);

// Filter elements that, within certain contexts, don't map their role.
// e.g. a <footer> inside a <main> is not a banner, but in the <body> context it is
if (typeof options.nativeScopeFilter === 'string') {
elms = elms.filter(elm => {
return (elm.actualNode.hasAttribute('role') ||
!axe.commons.dom.findUpVirtual(elm, options.nativeScopeFilter));
});
}

this.relatedNodes(elms.map(elm => elm.actualNode));

return elms.length <= 1;
16 changes: 16 additions & 0 deletions lib/rules/landmark-no-duplicate-banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "landmark-no-duplicate-banner",
"selector": "html",
"tags": [
"best-practice"
],
"metadata": {
"description": "Ensures the document has no more than one banner landmark",
"help": "Document contain at most one banner landmark"
},
"all": [],
"any": [
"page-no-duplicate-banner"
],
"none": []
}
16 changes: 16 additions & 0 deletions lib/rules/landmark-no-duplicate-contentinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "landmark-no-duplicate-contentinfo",
"selector": "html",
"tags": [
"best-practice"
],
"metadata": {
"description": "Ensures the document has no more than one contentinfo landmark",
"help": "Document contain at most one contentinfo landmark"
},
"all": [],
"any": [
"page-no-duplicate-contentinfo"
],
"none": []
}
16 changes: 0 additions & 16 deletions lib/rules/landmark-no-more-than-one-banner.json

This file was deleted.

16 changes: 0 additions & 16 deletions lib/rules/landmark-no-more-than-one-contentinfo.json

This file was deleted.

2 changes: 1 addition & 1 deletion lib/rules/landmark-one-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"all": [
"has-at-least-one-main",
"has-no-more-than-one-main"
"page-no-duplicate-main"
],
"any": [],
"none": []
Expand Down
50 changes: 0 additions & 50 deletions test/checks/keyboard/has-no-more-than-one-banner.js

This file was deleted.

50 changes: 0 additions & 50 deletions test/checks/keyboard/has-no-more-than-one-contentinfo.js

This file was deleted.

45 changes: 0 additions & 45 deletions test/checks/keyboard/has-no-more-than-one-main.js

This file was deleted.

Loading

0 comments on commit e75324b

Please sign in to comment.