@qualweb/act-rules 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ declare const _default: {
10
10
  meta: string[];
11
11
  svg: string[];
12
12
  'body *[lang]': string[];
13
- '[role="row"],[role="list"],[role="menu"],[role="menubar"],[role="listbox"],[role="grid"],[role="rowgroup"],[role="table"],[role="treegrid"],[role="tablist"]': string[];
13
+ '[role="row"],[role="list"],[role="menu"],[role="menubar"],[role="listbox"],[role="grid"],[role="rowgroup"],[role="table"],[role="treegrid"],[role="tablist"],ul,ol,menu,table,tr,thead,tbody,tfoot,datalist': string[];
14
14
  body: string[];
15
15
  'input, select, textarea, [role]': string[];
16
16
  '[role]': string[];
@@ -12,7 +12,7 @@ exports.default = {
12
12
  meta: ['QW-ACT-R4', 'QW-ACT-R71'],
13
13
  svg: ['QW-ACT-R21'],
14
14
  'body *[lang]': ['QW-ACT-R22'],
15
- '[role="row"],[role="list"],[role="menu"],[role="menubar"],[role="listbox"],[role="grid"],[role="rowgroup"],[role="table"],[role="treegrid"],[role="tablist"]': ['QW-ACT-R38'],
15
+ '[role="row"],[role="list"],[role="menu"],[role="menubar"],[role="listbox"],[role="grid"],[role="rowgroup"],[role="table"],[role="treegrid"],[role="tablist"],ul,ol,menu,table,tr,thead,tbody,tfoot,datalist': ['QW-ACT-R38'],
16
16
  body: ['QW-ACT-R62', 'QW-ACT-R9', 'QW-ACT-R10', 'QW-ACT-R25', 'QW-ACT-R27', 'QW-ACT-R28', 'QW-ACT-R34', 'QW-ACT-R44'],
17
17
  'input, select, textarea, [role]': ['QW-ACT-R16', 'QW-ACT-R41'],
18
18
  '[role]': ['QW-ACT-R20', 'QW-ACT-R33'],
@@ -821,7 +821,7 @@
821
821
  "name": "ARIA required owned elements",
822
822
  "code": "QW-ACT-R38",
823
823
  "mapping": "bc4a75",
824
- "description": "This rule checks that an element with an explicit semantic role has at least one of its required owned elements.",
824
+ "description": "This rule checks that an element with a semantic role that has required owned elements owns at least one of those required owned elements.",
825
825
  "metadata": {
826
826
  "target": {
827
827
  "element": "*",
@@ -1 +1 @@
1
- {"version":3,"file":"QW-ACT-R16.d.ts","sourceRoot":"","sources":["../../src/rules/QW-ACT-R16.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,cAAM,UAAW,SAAQ,UAAU;IAgBjC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAelC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"QW-ACT-R16.d.ts","sourceRoot":"","sources":["../../src/rules/QW-ACT-R16.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA6BtD,cAAM,UAAW,SAAQ,UAAU;IAGjC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CA6BlC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -13,8 +13,40 @@ exports.QW_ACT_R16 = void 0;
13
13
  const applicability_1 = require("@qualweb/util/applicability");
14
14
  const evaluation_1 = require("@qualweb/core/evaluation");
15
15
  const AtomicRule_object_1 = require("../lib/AtomicRule.object");
16
+ const applicableRoles = [
17
+ 'checkbox',
18
+ 'combobox',
19
+ 'listbox',
20
+ 'menuitemcheckbox',
21
+ 'menuitemradio',
22
+ 'radio',
23
+ 'searchbox',
24
+ 'slider',
25
+ 'spinbutton',
26
+ 'switch',
27
+ 'textbox'
28
+ ];
29
+ const applicableInputTypes = [
30
+ 'color',
31
+ 'date',
32
+ 'datetime-local',
33
+ 'file',
34
+ 'month',
35
+ 'password',
36
+ 'time',
37
+ 'week'
38
+ ];
16
39
  class QW_ACT_R16 extends AtomicRule_object_1.AtomicRule {
17
40
  execute(element) {
41
+ var _a;
42
+ const role = window.AccessibilityUtils.getElementRole(element);
43
+ const applicableByRole = !!role && applicableRoles.includes(role);
44
+ const applicableByInputType = !role &&
45
+ element.getElementTagName() === 'input' &&
46
+ applicableInputTypes.includes(((_a = element.getElementAttribute('type')) !== null && _a !== void 0 ? _a : '').toLowerCase());
47
+ if (!applicableByRole && !applicableByInputType) {
48
+ return;
49
+ }
18
50
  const test = new evaluation_1.Test();
19
51
  const accessibleName = window.AccessibilityUtils.getAccessibleName(element);
20
52
  if (accessibleName && accessibleName.trim() !== '') {
@@ -32,19 +64,6 @@ class QW_ACT_R16 extends AtomicRule_object_1.AtomicRule {
32
64
  exports.QW_ACT_R16 = QW_ACT_R16;
33
65
  __decorate([
34
66
  applicability_1.ElementExists,
35
- (0, applicability_1.ElementHasOneOfTheFollowingRoles)([
36
- 'checkbox',
37
- 'combobox',
38
- 'listbox',
39
- 'menuitemcheckbox',
40
- 'menuitemradio',
41
- 'radio',
42
- 'searchbox',
43
- 'slider',
44
- 'spinbutton',
45
- 'switch',
46
- 'textbox'
47
- ]),
48
67
  applicability_1.ElementIsInAccessibilityTree,
49
68
  __metadata("design:type", Function),
50
69
  __metadata("design:paramtypes", [Function]),
@@ -1 +1 @@
1
- {"version":3,"file":"QW-ACT-R38.d.ts","sourceRoot":"","sources":["../../src/rules/QW-ACT-R38.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,cAAM,UAAW,SAAQ,UAAU;IAQjC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;IA2BjC,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,8BAA8B;CAkBvC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"QW-ACT-R38.d.ts","sourceRoot":"","sources":["../../src/rules/QW-ACT-R38.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,cAAM,UAAW,SAAQ,UAAU;IAQjC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;IA8BjC,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,8BAA8B;CAkBvC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -15,13 +15,14 @@ const evaluation_1 = require("@qualweb/core/evaluation");
15
15
  const AtomicRule_object_1 = require("../lib/AtomicRule.object");
16
16
  class QW_ACT_R38 extends AtomicRule_object_1.AtomicRule {
17
17
  execute(element) {
18
+ var _a;
18
19
  const rolesJSON = window.AccessibilityUtils.roles;
19
20
  const test = new evaluation_1.Test();
20
- const explicitRole = element.getElementAttribute('role');
21
- const implicitRole = window.AccessibilityUtils.getImplicitRole(element, '');
21
+ const role = window.AccessibilityUtils.getElementRole(element);
22
+ const requiredOwnedElements = role ? (_a = rolesJSON[role]) === null || _a === void 0 ? void 0 : _a['requiredOwnedElements'] : undefined;
22
23
  const ariaBusy = this.isElementADescendantOfAriaBusy(element) || element.getElementAttribute('aria-busy');
23
- if (explicitRole !== null && explicitRole !== implicitRole && explicitRole !== 'combobox' && !ariaBusy) {
24
- const result = this.checkOwnedElementsRole(rolesJSON[explicitRole]['requiredOwnedElements'], window.AccessibilityUtils.getOwnedElements(element));
24
+ if (requiredOwnedElements && requiredOwnedElements.length > 0 && !ariaBusy) {
25
+ const result = this.checkOwnedElementsRole(requiredOwnedElements, window.AccessibilityUtils.getOwnedElements(element));
25
26
  if (result) {
26
27
  test.verdict = evaluation_1.Verdict.PASSED;
27
28
  test.resultCode = 'P1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qualweb/act-rules",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "ACT rules module for qualweb web accessibility evaluator",
5
5
  "files": [
6
6
  "dist/*"
@@ -45,10 +45,10 @@
45
45
  "author": "João Vicente",
46
46
  "license": "ISC",
47
47
  "devDependencies": {
48
- "@qualweb/core": "^0.8.12",
48
+ "@qualweb/core": "^0.9.1",
49
49
  "@qualweb/locale": "0.2.2",
50
50
  "@qualweb/qw-page": "0.3.7",
51
- "@qualweb/util": "0.7.1",
51
+ "@qualweb/util": "0.7.2",
52
52
  "@tsconfig/recommended": "^1.0.3",
53
53
  "@types/mocha": "^10.0.6",
54
54
  "@types/node": "^16.11.11",