-
Notifications
You must be signed in to change notification settings - Fork 469
feat(byRole): Add description filter #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import {elementRoles} from 'aria-query' | ||
import {computeAccessibleName} from 'dom-accessibility-api' | ||
import { | ||
computeAccessibleDescription, | ||
computeAccessibleName, | ||
} from 'dom-accessibility-api' | ||
import {prettyDOM} from './pretty-dom' | ||
import {getConfig} from './config' | ||
|
||
|
@@ -178,7 +181,7 @@ function getRoles(container, {hidden = false} = {}) { | |
}, {}) | ||
} | ||
|
||
function prettyRoles(dom, {hidden}) { | ||
function prettyRoles(dom, {hidden, includeDescription}) { | ||
const roles = getRoles(dom, {hidden}) | ||
// We prefer to skip generic role, we don't recommend it | ||
return Object.entries(roles) | ||
|
@@ -191,7 +194,20 @@ function prettyRoles(dom, {hidden}) { | |
computedStyleSupportsPseudoElements: | ||
getConfig().computedStyleSupportsPseudoElements, | ||
})}":\n` | ||
|
||
const domString = prettyDOM(el.cloneNode(false)) | ||
|
||
if (includeDescription) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we originally decide to always include it to help people discover the Though I don't think this necessarily applies to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look at the history. |
||
const descriptionString = `Description "${computeAccessibleDescription( | ||
el, | ||
{ | ||
computedStyleSupportsPseudoElements: | ||
getConfig().computedStyleSupportsPseudoElements, | ||
}, | ||
)}":\n` | ||
return `${nameString}${descriptionString}${domString}` | ||
} | ||
|
||
return `${nameString}${domString}` | ||
}) | ||
.join('\n\n') | ||
|
Uh oh!
There was an error while loading. Please reload this page.