Skip to content

Commit

Permalink
[New] element role mapping updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jlp-craigmorten authored and ljharb committed Apr 1, 2024
1 parent 24f2d0c commit c151daf
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
6 changes: 4 additions & 2 deletions __tests__/src/elementRoleMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ const entriesList = [
[{"name": "div"}, ["generic"]],
[{"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "footer"}, ["generic"]],
[{"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "header"}, ["generic"]],
[{"name": "hgroup"}, ["generic"]],
[{"name": "hgroup"}, ["group"]],
[{"name": "i"}, ["generic"]],
[{"name": "pre"}, ["generic"]],
[{"name": "q"}, ["generic"]],
[{"name": "s"}, ["deletion"]],
[{"name": "samp"}, ["generic"]],
[{"name": "search"}, ["search"]],
[{"name": "section"}, ["generic"]],
[{"name": "small"}, ["generic"]],
[{"name": "span"}, ["generic"]],
Expand Down Expand Up @@ -132,7 +134,7 @@ const entriesList = [
test('elementRoleMap API', (t) => {
const predicate = (obj, [o]) => deepEqual(o, obj);

testIteration(t, elementRoleMap, entriesList, 113, predicate);
testIteration(t, elementRoleMap, entriesList, 115, predicate);

testForEach(t, elementRoleMap, entriesList, predicate);

Expand Down
9 changes: 5 additions & 4 deletions __tests__/src/roleElementMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ const entriesList = [
["complementary", [{"constraints": ["scoped to the body element", "scoped to the main element"], "name": "aside"}, {"attributes": [{"constraints": ["set"], "name": "aria-label"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}]],
["contentinfo", [{"constraints": ["scoped to the body element"], "name": "footer"}]],
["definition", [{"name": "dd"}]],
["deletion", [{"name": "del"}]],
["deletion", [{"name": "del"}, {"name": "s"}]],
["dialog", [{"name": "dialog"}]],
["document", [{"name": "html"}]],
["emphasis", [{"name": "em"}]],
["figure", [{"name": "figure"}]],
["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]],
["generic", [{"name": "a"}, {"name": "area"}, {"name": "aside"}, {"name": "b"}, {"name": "bdo"}, {"name": "body"}, {"name": "data"}, {"name": "div"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "footer"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "header"}, {"name": "hgroup"}, {"name": "i"}, {"name": "pre"}, {"name": "q"}, {"name": "samp"}, {"name": "section"}, {"name": "small"}, {"name": "span"}, {"name": "u"}]],
["generic", [{"name": "a"}, {"name": "area"}, {"name": "aside"}, {"name": "b"}, {"name": "bdo"}, {"name": "body"}, {"name": "data"}, {"name": "div"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "footer"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "header"}, {"name": "i"}, {"name": "pre"}, {"name": "q"}, {"name": "samp"}, {"name": "section"}, {"name": "small"}, {"name": "span"}, {"name": "u"}]],
["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]],
["gridcell", [{"constraints": ["ancestor table element has grid role", "ancestor table element has treegrid role"], "name": "td"}]],
["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}, {"name": "address"}]],
["group", [{"name": "address"}, {"name": "details"}, {"name": "fieldset"}, {"name": "hgroup"}, {"name": "optgroup"}]],
["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]],
["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]],
["insertion", [{"name": "ins"}]],
Expand All @@ -54,6 +54,7 @@ const entriesList = [
["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]],
["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]],
["section", [{"attributes": [{"name": "aria-label"}], "name": "section"}, {"attributes": [{"name": "aria-labelledby"}], "name": "section"}]],
["search", [{"name": "search"}]],
["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "name": "input"}]],
["separator", [{"name": "hr"}]],
["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]],
Expand All @@ -73,7 +74,7 @@ const entriesList = [
test('roleElementMap API', (t) => {
const predicate = (role, [r]) => role === r;

testIteration(t, roleElementMap, entriesList, 56, predicate);
testIteration(t, roleElementMap, entriesList, 57, predicate);

testForEach(t, roleElementMap, entriesList, predicate);

Expand Down
31 changes: 22 additions & 9 deletions scripts/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,12 @@
"name": "del"
},
"module": "HTML"
},
{
"concept": {
"name": "s"
},
"module": "HTML"
}
],
"requiredContextRole": [],
Expand Down Expand Up @@ -3109,12 +3115,6 @@
},
"module": "HTML"
},
{
"concept": {
"name": "hgroup"
},
"module": "HTML"
},
{
"concept": {
"name": "i"
Expand Down Expand Up @@ -3447,6 +3447,12 @@
"aria-roledescription"
],
"relatedConcepts": [
{
"concept": {
"name": "address"
},
"module": "HTML"
},
{
"concept": {
"name": "details"
Expand All @@ -3461,13 +3467,13 @@
},
{
"concept": {
"name": "optgroup"
"name": "hgroup"
},
"module": "HTML"
},
{
"concept": {
"name": "address"
"name": "optgroup"
},
"module": "HTML"
}
Expand Down Expand Up @@ -5174,7 +5180,14 @@
"aria-relevant",
"aria-roledescription"
],
"relatedConcepts": [],
"relatedConcepts": [
{
"concept": {
"name": "search"
},
"module": "HTML"
}
],
"requiredContextRole": [],
"requiredOwnedElements": [],
"requiredProps": [],
Expand Down
6 changes: 6 additions & 0 deletions src/etc/roles/literal/deletionRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const deletionRole: ARIARoleDefinition = {
},
module: 'HTML',
},
{
concept: {
name: 's',
},
module: 'HTML',
},
],
requireContextRole: [],
requiredContextRole: [],
Expand Down
6 changes: 0 additions & 6 deletions src/etc/roles/literal/genericRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ const genericRole: ARIARoleDefinition = {
},
module: 'HTML',
},
{
concept: {
name: 'hgroup',
},
module: 'HTML',
},
{
concept: {
name: 'i',
Expand Down
10 changes: 8 additions & 2 deletions src/etc/roles/literal/groupRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const groupRole: ARIARoleDefinition = {
'aria-disabled': null,
},
relatedConcepts: [
{
concept: {
name: 'address',
},
module: 'HTML',
},
{
concept: {
name: 'details',
Expand All @@ -29,13 +35,13 @@ const groupRole: ARIARoleDefinition = {
},
{
concept: {
name: 'optgroup',
name: 'hgroup',
},
module: 'HTML',
},
{
concept: {
name: 'address',
name: 'optgroup',
},
module: 'HTML',
},
Expand Down
9 changes: 8 additions & 1 deletion src/etc/roles/literal/searchRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ const searchRole: ARIARoleDefinition = {
],
prohibitedProps: [],
props: {},
relatedConcepts: [],
relatedConcepts: [
{
concept: {
name: 'search',
},
module: 'HTML',
},
],
requireContextRole: [],
requiredContextRole: [],
requiredOwnedElements: [],
Expand Down

0 comments on commit c151daf

Please sign in to comment.