Skip to content

Commit

Permalink
chore: duplicate-id editorial
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Aug 24, 2018
1 parent 2ecfea7 commit 22d5ba7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| definition-list | Ensures <dl> elements are structured correctly | Serious | cat.structure, wcag2a, wcag131 | true |
| dlitem | Ensures <dt> and <dd> elements are contained by a <dl> | Serious | cat.structure, wcag2a, wcag131 | true |
| document-title | Ensures each HTML document contains a non-empty <title> element | Serious | cat.text-alternatives, wcag2a, wcag242 | true |
| duplicate-id-active | Ensures every id attribute value is unique | Serious | cat.parsing, wcag2a, wcag411 | true |
| duplicate-id-active | Ensures every id attribute value of active elements is unique | Serious | cat.parsing, wcag2a, wcag411 | true |
| duplicate-id-aria | Ensures every id attribute value used in ARIA and in labels is unique | Critical | cat.parsing, wcag2a, wcag411 | true |
| duplicate-id | Ensures every id attribute value is unique | Minor | cat.parsing, wcag2a, wcag411 | true |
| empty-heading | Ensures headings have discernible text | Minor | cat.name-role-value, best-practice | true |
Expand Down
4 changes: 2 additions & 2 deletions lib/checks/parsing/duplicate-id-active.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"impact": "serious",
"messages": {
"pass": "Document has no elements that share the same id attribute",
"fail": "Document has multiple elements with the same id attribute: {{=it.data}}"
"pass": "Document has no active elements that share the same id attribute",
"fail": "Document has active elements with the same id attribute: {{=it.data}}"
}
}
}
4 changes: 2 additions & 2 deletions lib/checks/parsing/duplicate-id-aria.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"impact": "critical",
"messages": {
"pass": "Document has no elements that share the same id attribute",
"fail": "Document has multiple elements with the same id attribute: {{=it.data}}"
"pass": "Document has no elements referenced with ARIA or labels that share the same id attribute",
"fail": "Document has multiple elements referenced with ARIA or with the same id attribute: {{=it.data}}"
}
}
}
7 changes: 2 additions & 5 deletions lib/checks/parsing/duplicate-id.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { dom, utils } = axe.commons;
const id = node.getAttribute('id').trim();
const root = dom.getRootNode(node);

// Since empty ID's are not meaningful and are ignored by Edge, we'll
// let those pass.
if (!id) {
return true;
}

const root = axe.commons.dom.getRootNode(node);
const matchingNodes = Array.from(
root.querySelectorAll(`[id="${utils.escapeSelector(id)}"]`)
root.querySelectorAll(`[id="${axe.commons.utils.escapeSelector(id)}"]`)
).filter(foundNode => foundNode !== node);

if (matchingNodes.length) {
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/duplicate-id-active.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"wcag411"
],
"metadata": {
"description": "Ensures every id attribute value is unique",
"description": "Ensures every id attribute value of active elements is unique",
"help": "IDs of active elements must be unique"
},
"all": [
"all": [],
"any": [
"duplicate-id-active"
],
"any": [],
"none": []
}
4 changes: 2 additions & 2 deletions lib/rules/duplicate-id-aria.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"description": "Ensures every id attribute value used in ARIA and in labels is unique",
"help": "IDs used in ARIA and labels must be unique"
},
"all": [
"all": [],
"any": [
"duplicate-id-aria"
],
"any": [],
"none": []
}
4 changes: 2 additions & 2 deletions lib/rules/duplicate-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"description": "Ensures every id attribute value is unique",
"help": "id attribute value must be unique"
},
"all": [
"all": [],
"any": [
"duplicate-id"
],
"any": [],
"none": []
}

0 comments on commit 22d5ba7

Please sign in to comment.