-
Notifications
You must be signed in to change notification settings - Fork 775
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
fix(2859) presentation role conflict #2948
Changes from all commits
cf70404
38f7b0a
8f5111c
ee8bc8d
2fa9ec6
3b54401
2c2033d
d3a80b0
5061e98
81836d2
13a6635
1844833
b15be4f
3b2cb81
d76b53e
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,6 @@ | ||
import implicitHtmlRoles from '../standards/implicit-html-roles'; | ||
import { getNodeFromTree } from '../../core/utils'; | ||
import getElementSpec from '../standards/get-element-spec'; | ||
import AbstractVirtuaNode from '../../core/base/virtual-node/abstract-virtual-node'; | ||
|
||
/** | ||
|
@@ -10,7 +11,7 @@ import AbstractVirtuaNode from '../../core/base/virtual-node/abstract-virtual-no | |
* @param {HTMLElement|VirtualNode} node The node to test | ||
* @return {Mixed} Either the role or `null` if there is none | ||
*/ | ||
function implicitRole(node) { | ||
function implicitRole(node, { chromium } = {}) { | ||
const vNode = | ||
node instanceof AbstractVirtuaNode ? node : getNodeFromTree(node); | ||
node = vNode.actualNode; | ||
|
@@ -25,24 +26,19 @@ function implicitRole(node) { | |
); | ||
} | ||
|
||
// until we have proper implicit role lookups for svgs we will | ||
// avoid giving them one | ||
if (node && node.namespaceURI === 'http://www.w3.org/2000/svg') { | ||
return null; | ||
} | ||
Comment on lines
-28
to
-32
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. Why did you remove this? 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. It looked like an unnecessary check - we don't have implicit role lookups for svg, so it will return null without this check based on the lines that follow. If we left it in, we'd have to add another check here for whether to use the chromium roles, and return the svg's implicit chromium role or else null. That's the same logic as is below. |
||
|
||
const nodeName = vNode.props.nodeName; | ||
const role = implicitHtmlRoles[nodeName]; | ||
|
||
if (!role) { | ||
return null; | ||
if (!role && chromium) { | ||
const { chromiumRole } = getElementSpec(vNode); | ||
return chromiumRole || null; | ||
} | ||
|
||
if (typeof role === 'function') { | ||
return role(vNode); | ||
} | ||
|
||
return role; | ||
return role || null; | ||
} | ||
|
||
export default implicitRole; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getImplicitRole } from '../commons/aria'; | ||
|
||
function hasImplicitChromiumRoleMatches(node, virtualNode) { | ||
return getImplicitRole(virtualNode, { chromium: true }) !== null; | ||
} | ||
|
||
export default hasImplicitChromiumRoleMatches; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getImplicitRole } from '../commons/aria'; | ||
|
||
function presentationRoleConflictMatches(node, virtualNode) { | ||
return getImplicitRole(virtualNode, { chromiumRoles: true }) !== null; | ||
} | ||
|
||
export default presentationRoleConflictMatches; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,8 @@ const htmlElms = { | |
}, | ||
// Note: if the property applies regardless of variants it is | ||
// placed at the top level instead of the default variant | ||
allowedRoles: ['application'] | ||
allowedRoles: ['application'], | ||
chromiumRole: 'Audio' | ||
}, | ||
b: { | ||
contentTypes: ['phrasing', 'flow'], | ||
|
@@ -143,7 +144,8 @@ const htmlElms = { | |
}, | ||
canvas: { | ||
allowedRoles: true, | ||
contentTypes: ['embedded', 'phrasing', 'flow'] | ||
contentTypes: ['embedded', 'phrasing', 'flow'], | ||
chromiumRole: 'Canvas' | ||
}, | ||
caption: { | ||
allowedRoles: false | ||
|
@@ -205,7 +207,8 @@ const htmlElms = { | |
}, | ||
dl: { | ||
contentTypes: ['flow'], | ||
allowedRoles: ['group', 'list', 'presentation', 'none'] | ||
allowedRoles: ['group', 'list', 'presentation', 'none'], | ||
chromiumRole: 'DescriptionList' | ||
}, | ||
dt: { | ||
allowedRoles: ['listitem'] | ||
|
@@ -216,7 +219,8 @@ const htmlElms = { | |
}, | ||
embed: { | ||
contentTypes: ['interactive', 'embedded', 'phrasing', 'flow'], | ||
allowedRoles: ['application', 'document', 'img', 'presentation', 'none'] | ||
allowedRoles: ['application', 'document', 'img', 'presentation', 'none'], | ||
chromiumRole: 'EmbeddedObject' | ||
}, | ||
fieldset: { | ||
contentTypes: ['flow'], | ||
|
@@ -320,7 +324,8 @@ const htmlElms = { | |
}, | ||
iframe: { | ||
contentTypes: ['interactive', 'embedded', 'phrasing', 'flow'], | ||
allowedRoles: ['application', 'document', 'img', 'none', 'presentation'] | ||
allowedRoles: ['application', 'document', 'img', 'none', 'presentation'], | ||
chromiumRole: 'Iframe' | ||
}, | ||
img: { | ||
variant: { | ||
|
@@ -525,7 +530,8 @@ const htmlElms = { | |
}, | ||
label: { | ||
contentTypes: ['interactive', 'phrasing', 'flow'], | ||
allowedRoles: false | ||
allowedRoles: false, | ||
chromiumRole: 'Label' | ||
}, | ||
legend: { | ||
allowedRoles: false | ||
|
@@ -601,7 +607,8 @@ const htmlElms = { | |
}, | ||
meter: { | ||
contentTypes: ['phrasing', 'flow'], | ||
allowedRoles: false | ||
allowedRoles: false, | ||
chromiumRole: 'progressbar' | ||
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. Should this be capitalised? If it isn't in Chromium then not, but it seems inconsistent. 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. Yep, they are all inconsistent in Chrome(ium) |
||
}, | ||
nav: { | ||
contentTypes: ['sectioning', 'flow'], | ||
|
@@ -623,7 +630,8 @@ const htmlElms = { | |
contentTypes: ['embedded', 'phrasing', 'flow'] | ||
} | ||
}, | ||
allowedRoles: ['application', 'document', 'img'] | ||
allowedRoles: ['application', 'document', 'img'], | ||
chromiumRole: 'PluginObject' | ||
}, | ||
ol: { | ||
contentTypes: ['flow'], | ||
|
@@ -814,6 +822,7 @@ const htmlElms = { | |
svg: { | ||
contentTypes: ['embedded', 'phrasing', 'flow'], | ||
allowedRoles: ['application', 'document', 'img'], | ||
chromiumRole: 'SVGRoot', | ||
namingMethods: ['svgTitleText'] | ||
}, | ||
sub: { | ||
|
@@ -914,7 +923,8 @@ const htmlElms = { | |
contentTypes: ['embedded', 'phrasing', 'flow'] | ||
} | ||
}, | ||
allowedRoles: ['application'] | ||
allowedRoles: ['application'], | ||
chromiumRole: 'video' | ||
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. Same here. Why is it 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. Same answer - it's inconsistently reported in the browser. |
||
}, | ||
wbr: { | ||
contentTypes: ['phrasing', 'flow'], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div id="pass1" role="presentation">Test</div> | ||
<div id="pass2" role="presentation">Test Button</div> | ||
clottman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<li id="violation1" role="presentation" aria-label="My Heading">Hello</li> | ||
<h1 id="violation2" role="none" aria-label="My Heading">Hello</h1> | ||
<div id="inapplicable1" role="presentation">Test</div> | ||
<div id="inapplicable2" role="presentation">Test Button</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"rule": "presentation-role-conflict", | ||
"description": "presentation-role-conflict tests", | ||
"violations": [["#violation1"], ["#violation2"]], | ||
"passes": [["#pass1"], ["#pass2"]] | ||
"violations": [["#violation1"], ["#violation2"]] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd, looks like prettier isn't running on my machine :/. I'll have to look at that.