Skip to content

Commit fda2c97

Browse files
fix: amend breaking changes and reinstate constraints (#515)
* fix: align `roles.json` with stable specs * feat: reinstate constraints properties where no value is specified * feat: generate role files * Update package.json Co-authored-by: Craig Morten <[email protected]> --------- Co-authored-by: Craig Morten <[email protected]>
1 parent f9f9ea6 commit fda2c97

20 files changed

+1262
-377
lines changed

Diff for: __tests__/src/elementRoleMap-test.js

+30-30
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ const entriesList = [
1717
[{"name": "th"}, ["columnheader"]],
1818
[{"attributes": [{"name": "scope", "value": "col"}], "name": "th"}, ["columnheader"]],
1919
[{"attributes": [{"name": "scope", "value": "colgroup"}], "name": "th"}, ["columnheader"]],
20-
[{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "email"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]],
21-
[{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]],
22-
[{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "tel"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]],
23-
[{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "text"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]],
24-
[{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "url"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]],
25-
[{"attributes": [{"name": "multiple"}, {"name": "size"}], "constraints": ["the multiple attribute and the size attribute do not have a value greater than 1"], "name": "select"}, ["combobox"]],
20+
[{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]],
21+
[{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]],
22+
[{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]],
23+
[{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]],
24+
[{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]],
25+
[{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "constraints": ["the multiple attribute is not set and the size attribute does not have a value greater than 1"], "name": "select"}, ["combobox"]],
2626
[{"name": "aside"}, ["complementary"]],
27-
[{"attributes": [{"name": "aria-label"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]],
28-
[{"attributes": [{"name": "aria-labelledby"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]],
27+
[{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]],
28+
[{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]],
2929
[{"constraints": ["scoped to the body element"], "name": "footer"}, ["contentinfo"]],
3030
[{"name": "dd"}, ["definition"]],
3131
[{"name": "del"}, ["deletion"]],
3232
[{"name": "dialog"}, ["dialog"]],
3333
[{"name": "em"}, ["emphasis"]],
3434
[{"name": "html"}, ["document"]],
3535
[{"name": "figure"}, ["figure"]],
36-
[{"attributes": [{"name": "aria-label"}], "name": "form"}, ["form"]],
37-
[{"attributes": [{"name": "aria-labelledby"}], "name": "form"}, ["form"]],
38-
[{"attributes": [{"name": "name"}], "name": "form"}, ["form"]],
36+
[{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]],
37+
[{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]],
38+
[{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]],
3939
[{"name": "a"}, ["generic"]],
4040
[{"name": "area"}, ["generic"]],
4141
[{"name": "aside"}, ["generic"]],
@@ -55,7 +55,7 @@ const entriesList = [
5555
[{"name": "small"}, ["generic"]],
5656
[{"name": "span"}, ["generic"]],
5757
[{"name": "u"}, ["generic"]],
58-
[{"constraints": ["ancestor table element has grid role"], "name": "td"}, ["gridcell"]],
58+
[{"constraints": ["ancestor table element has grid role", "ancestor table element has treegrid role"], "name": "td"}, ["gridcell"]],
5959
[{"name": "details"}, ["group"]],
6060
[{"name": "fieldset"}, ["group"]],
6161
[{"name": "optgroup"}, ["group"]],
@@ -66,17 +66,17 @@ const entriesList = [
6666
[{"name": "h4"}, ["heading"]],
6767
[{"name": "h5"}, ["heading"]],
6868
[{"name": "h6"}, ["heading"]],
69-
[{"name": "img"}, ["img"]],
69+
[{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]],
70+
[{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]],
7071
[{"name": "ins"}, ["insertion"]],
71-
[{"attributes": [{"name": "href"}], "name": "a"}, ["link"]],
72-
[{"attributes": [{"name": "href"}], "name": "area"}, ["link"]],
72+
[{"attributes": [{"constraints": ["set"], "name": "href"}], "name": "a"}, ["link"]],
73+
[{"attributes": [{"constraints": ["set"], "name": "href"}], "name": "area"}, ["link"]],
7374
[{"name": "menu"}, ["list"]],
7475
[{"name": "ol"}, ["list"]],
7576
[{"name": "ul"}, ["list"]],
76-
[{"attributes": [{"name": "size"}, {"name": "multiple"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, ["listbox"]],
77-
[{"attributes": [{"name": "size"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, ["listbox"]],
78-
[{"attributes": [{"name": "multiple"}], "constraints": ["the multiple attribute value is greater than 1"], "name": "select"}, ["listbox"]],
79-
[{"attributes": [{"name": "aria-multiselectable", "value": "true"}], "constraints": ["the datalist selection model allows multiple option elements to be selected at a time"], "name": "datalist"}, ["listbox"]],
77+
[{"attributes": [{"constraints": [">1"], "name": "size"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, ["listbox"]],
78+
[{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]],
79+
[{"name": "datalist"}, ["listbox"]],
8080
[{"attributes": [{"name": "aria-multiselectable", "value": "false"}], "name": "datalist"}, ["listbox"]],
8181
[{"constraints": ["direct descendant of ol", "direct descendant of ul", "direct descendant of menu"], "name": "li"}, ["listitem"]],
8282
[{"name": "main"}, ["main"]],
@@ -90,16 +90,16 @@ const entriesList = [
9090
[{"name": "progress"}, ["progressbar"]],
9191
[{"attributes": [{"name": "aria-valuemax"}, {"name": "aria-valuemin", "value": 0}, {"name": "aria-valuenow"}], "constraints": ["the progress bar is determinate"],"name": "progress"}, ["progressbar"]],
9292
[{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]],
93-
[{"attributes": [{"name": "aria-label"}], "name": "section"}, ["region"]],
94-
[{"attributes": [{"name": "aria-labelledby"}], "name": "section"}, ["region"]],
93+
[{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]],
94+
[{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]],
9595
[{"name": "tr"}, ["row"]],
9696
[{"name": "tbody"}, ["rowgroup"]],
9797
[{"constraints": ["ancestor table element has table role"], "name": "td"}, ["cell"]],
9898
[{"name": "tfoot"}, ["rowgroup"]],
9999
[{"name": "thead"}, ["rowgroup"]],
100100
[{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]],
101101
[{"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}, ["rowheader"]],
102-
[{"attributes": [{"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["searchbox"]],
102+
[{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["searchbox"]],
103103
[{"attributes": [{"name": "aria-label"}], "name": "section"}, ["section"]],
104104
[{"attributes": [{"name": "aria-labelledby"}], "name": "section"}, ["section"]],
105105
[{"name": "hr"}, ["separator"]],
@@ -113,11 +113,11 @@ const entriesList = [
113113
[{"name": "table"}, ["table"]],
114114
[{"name": "dfn"}, ["term"]],
115115
[{"name": "dt"}, ["term"]],
116-
[{"constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
117-
[{"attributes": [{"name": "type", "value": "email"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
118-
[{"attributes": [{"name": "type", "value": "tel"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
119-
[{"attributes": [{"name": "type", "value": "text"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
120-
[{"attributes": [{"name": "type", "value": "url"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
116+
[{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
117+
[{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
118+
[{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
119+
[{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
120+
[{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]],
121121
[{"name": "textarea"}, ["textbox"]],
122122
[{"name": "time"}, ["time"]],
123123
];
@@ -158,7 +158,7 @@ describe('elementRoleMap API', function () {
158158
it('get()', function () {
159159
expect(elementRoleMap.get({
160160
attributes: [
161-
{ name: 'href' }
161+
{ constraints: ["set"], name: 'href' }
162162
],
163163
name: 'a'
164164
})).toEqual(
@@ -184,7 +184,7 @@ describe('elementRoleMap API', function () {
184184
it('has()', function () {
185185
expect(elementRoleMap.has({
186186
attributes: [
187-
{ name: 'href' }
187+
{ constraints: ["set"], name: 'href' }
188188
],
189189
name: 'a'
190190
})).toEqual(true);
@@ -230,7 +230,7 @@ describe('elementRolesMap', function () {
230230
});
231231
describe('spread operator', function () {
232232
it('should have a specific length', function () {
233-
expect([...elementRoleMap].length).toEqual(118);
233+
expect([...elementRoleMap].length).toEqual(113);
234234
});
235235
test.each([...elementRoleMap])('Testing element: %o', (obj, roles) => {
236236
expect(entriesList).toEqual(

0 commit comments

Comments
 (0)