-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(duplicate-id): Add shadow DOM support
- Loading branch information
1 parent
9df8c9c
commit 439bc71
Showing
2 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
const id = node.getAttribute('id').trim(); | ||
// Since empty ID's are not meaningful and are ignored by Edge, we'll | ||
// let those pass. | ||
if (!node.getAttribute('id').trim()) { | ||
if (!id) { | ||
return true; | ||
} | ||
const root = axe.commons.dom.getRootNode(node); | ||
const matchingNodes = Array.from(root.querySelectorAll( | ||
`[id="${ axe.commons.utils.escapeSelector(id) }"]` | ||
)).filter(foundNode => foundNode !== node); | ||
|
||
const id = axe.commons.utils.escapeSelector(node.getAttribute('id')); | ||
var matchingNodes = document.querySelectorAll(`[id="${id}"]`); | ||
var related = []; | ||
|
||
for (var i = 0; i < matchingNodes.length; i++) { | ||
if (matchingNodes[i] !== node) { | ||
related.push(matchingNodes[i]); | ||
} | ||
} | ||
if (related.length) { | ||
this.relatedNodes(related); | ||
if (matchingNodes.length) { | ||
this.relatedNodes(matchingNodes); | ||
} | ||
this.data(node.getAttribute('id')); | ||
this.data(id); | ||
|
||
return (matchingNodes.length <= 1); | ||
return (matchingNodes.length === 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters