-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Run text.accessibleText() on virtual elements (#420)
- Loading branch information
1 parent
0478cbd
commit 414fcbe
Showing
16 changed files
with
585 additions
and
282 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* global axe, dom */ | ||
/** | ||
* Find elements referenced from a given context | ||
* | ||
* @param object { | ||
* context: Node | virtual node Element in the same context | ||
* value: String attribute value to search for | ||
* attr: String attribute name to search for | ||
* elm: String ndoeName to search for (optional) | ||
* } | ||
* @return Array[Node] | ||
*/ | ||
dom.findElmsInContext = function ({ context, value, attr, elm = '' }) { | ||
let root; | ||
context = context.actualNode || context; | ||
const escapedValue = axe.utils.escapeSelector(value); | ||
|
||
if (context.nodeType === 9 || context.nodeType === 11) { // It's already root | ||
root = context; | ||
} else { | ||
root = dom.getRootNode(context); | ||
} | ||
return Array.from( | ||
root.querySelectorAll(elm + '[' + attr + '=' + escapedValue + ']') | ||
); | ||
}; |
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
Oops, something went wrong.