@qualweb/best-practices 0.7.10 → 0.7.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"QW-BP28.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP28.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAGhC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAuDlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"QW-BP28.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP28.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAGhC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAiClC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -19,27 +19,7 @@ class QW_BP28 extends BestPractice_object_1.BestPractice {
19
19
  let resultCode;
20
20
  const candidates = element.getElements('h1, [role="heading"][aria-level="1"]');
21
21
  const accessibleH1s = candidates.filter(h1 => {
22
- const hasText = h1.getElementText().trim().length > 0;
23
- const rect = h1.getBoundingBox();
24
- const hasSize = rect.width > 0 && rect.height > 0;
25
- if (!hasText || !hasSize || h1.isOffScreen()) {
26
- return false;
27
- }
28
- let parent = h1.getElementParent();
29
- while (parent) {
30
- const propertyDisplay = parent.getElementStyleProperty('display', null);
31
- const propertyAriaHidden = parent.getElementAttribute('aria-hidden') === 'true';
32
- const propertyOverflow = parent.getElementStyleProperty('overflow', null);
33
- const boxDimensions = parent.getBoundingBox();
34
- if (propertyDisplay === 'none' || propertyAriaHidden) {
35
- return false;
36
- }
37
- if ((boxDimensions.height <= 0 || boxDimensions.width <= 0) && propertyOverflow === 'hidden') {
38
- return false;
39
- }
40
- parent = parent.getElementParent();
41
- }
42
- return true;
22
+ return window.AccessibilityUtils.isElementInAT(h1);
43
23
  });
44
24
  const count = accessibleH1s.length;
45
25
  if (count === 1) {
@@ -48,12 +28,12 @@ class QW_BP28 extends BestPractice_object_1.BestPractice {
48
28
  }
49
29
  else if (count > 1) {
50
30
  verdict = evaluation_1.Verdict.FAILED;
51
- resultCode = 'F1';
31
+ resultCode = 'F2';
52
32
  }
53
33
  else {
54
34
  const test = new evaluation_1.Test();
55
35
  test.verdict = evaluation_1.Verdict.FAILED;
56
- test.resultCode = 'F2';
36
+ test.resultCode = 'F1';
57
37
  return this.addTestResult(test);
58
38
  }
59
39
  candidates.forEach((element) => {
@@ -0,0 +1,8 @@
1
+ import type { QWElement } from '@qualweb/qw-element';
2
+ import { BestPractice } from '../lib/BestPractice.object';
3
+ declare class QW_BP30 extends BestPractice {
4
+ private readonly idMap;
5
+ execute(element: QWElement): void;
6
+ }
7
+ export { QW_BP30 };
8
+ //# sourceMappingURL=QW-BP30.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QW-BP30.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP30.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IAGpD,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAwBlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.QW_BP30 = void 0;
13
+ const applicability_1 = require("@qualweb/util/applicability");
14
+ const evaluation_1 = require("@qualweb/core/evaluation");
15
+ const BestPractice_object_1 = require("../lib/BestPractice.object");
16
+ class QW_BP30 extends BestPractice_object_1.BestPractice {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.idMap = new Map();
20
+ }
21
+ execute(element) {
22
+ const test = new evaluation_1.Test();
23
+ const id = element.getElementAttribute('id');
24
+ if (id && !this.idMap.get(id)) {
25
+ try {
26
+ const elementsWithSameId = window.qwPage.getElements(`[id="${id}"]`, element);
27
+ const visibleElementsWithSameId = elementsWithSameId.filter(el => (window.AccessibilityUtils.isElementInAT(el)));
28
+ if (visibleElementsWithSameId.length > 1) {
29
+ test.verdict = evaluation_1.Verdict.FAILED;
30
+ test.resultCode = 'F1';
31
+ }
32
+ else {
33
+ test.verdict = evaluation_1.Verdict.PASSED;
34
+ test.resultCode = 'P1';
35
+ }
36
+ test.addElements(visibleElementsWithSameId);
37
+ this.addTestResult(test);
38
+ }
39
+ finally {
40
+ this.idMap.set(id, true);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ exports.QW_BP30 = QW_BP30;
46
+ __decorate([
47
+ applicability_1.ElementExists,
48
+ __metadata("design:type", Function),
49
+ __metadata("design:paramtypes", [Function]),
50
+ __metadata("design:returntype", void 0)
51
+ ], QW_BP30.prototype, "execute", null);
@@ -24,4 +24,5 @@ export * from './QW-BP6';
24
24
  export * from './QW-BP7';
25
25
  export * from './QW-BP8';
26
26
  export * from './QW-BP9';
27
+ export * from './QW-BP30';
27
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/best-practices/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/best-practices/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -40,3 +40,4 @@ __exportStar(require("./QW-BP6"), exports);
40
40
  __exportStar(require("./QW-BP7"), exports);
41
41
  __exportStar(require("./QW-BP8"), exports);
42
42
  __exportStar(require("./QW-BP9"), exports);
43
+ __exportStar(require("./QW-BP30"), exports);
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -314,5 +314,26 @@
314
314
  "element": "html"
315
315
  }
316
316
  }
317
+ },
318
+ "QW_BP30": {
319
+ "name": "id attribute value is unique",
320
+ "code": "QW-BP30",
321
+ "description": "This best practice checks that all id attribute values on a single page are unique.",
322
+ "metadata": {
323
+ "target": {
324
+ "element": "*"
325
+ },
326
+ "success-criteria": [
327
+ {
328
+ "name": "4.1.1",
329
+ "level": "A",
330
+ "principle": "Robust",
331
+ "url": "https://www.w3.org/WAI/WCAG21/Understanding/parsing.html",
332
+ "url_tr": "https://www.w3.org/TR/WCAG21/#parsing"
333
+ }
334
+ ],
335
+ "related": ["H93"],
336
+ "url": "https://www.w3.org/WAI/WCAG21/Techniques/html/H93"
337
+ }
317
338
  }
318
339
  }
@@ -19,6 +19,7 @@ declare const _default: {
19
19
  'footer:not([role]), [role=contentinfo]': string[];
20
20
  'main:not([role]), [role=main]': string[];
21
21
  html: string[];
22
+ '*[id]': string[];
22
23
  };
23
24
  export default _default;
24
25
  //# sourceMappingURL=mapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/lib/mapping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wBAqBE"}
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/lib/mapping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAuBE"}
@@ -20,5 +20,6 @@ exports.default = {
20
20
  'aside:not([role]), [role=complementary]': ['QW-BP25'],
21
21
  'footer:not([role]), [role=contentinfo]': ['QW-BP26'],
22
22
  'main:not([role]), [role=main]': ['QW-BP27'],
23
- html: ['QW-BP29']
23
+ html: ['QW-BP29'],
24
+ '*[id]': ['QW-BP30']
24
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qualweb/best-practices",
3
- "version": "0.7.10",
3
+ "version": "0.7.12",
4
4
  "description": "QualWeb best practices",
5
5
  "files": [
6
6
  "dist/*"
@@ -66,10 +66,10 @@
66
66
  "author": "João Vicente",
67
67
  "license": "ISC",
68
68
  "devDependencies": {
69
- "@qualweb/core": "^0.8.9",
69
+ "@qualweb/core": "^0.8.10",
70
70
  "@qualweb/locale": "0.2.2",
71
- "@qualweb/qw-page": "0.3.5",
72
- "@qualweb/util": "0.6.5",
71
+ "@qualweb/qw-page": "0.3.6",
72
+ "@qualweb/util": "0.6.6",
73
73
  "@tsconfig/recommended": "^1.0.3",
74
74
  "@types/mocha": "^10.0.6",
75
75
  "@types/node": "^16.11.12",