@qualweb/best-practices 0.7.7 → 0.7.9
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;
|
|
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;CAqDlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -17,24 +17,44 @@ class QW_BP28 extends BestPractice_object_1.BestPractice {
|
|
|
17
17
|
execute(element) {
|
|
18
18
|
let verdict;
|
|
19
19
|
let resultCode;
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const candidates = element.getElements('h1, [role="heading"][aria-level="1"]');
|
|
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;
|
|
43
|
+
});
|
|
44
|
+
const count = accessibleH1s.length;
|
|
45
|
+
if (count <= 1) {
|
|
22
46
|
verdict = evaluation_1.Verdict.PASSED;
|
|
23
47
|
resultCode = 'P1';
|
|
24
48
|
}
|
|
25
|
-
else if (
|
|
49
|
+
else if (count > 1) {
|
|
26
50
|
verdict = evaluation_1.Verdict.FAILED;
|
|
27
51
|
resultCode = 'F1';
|
|
28
|
-
const test = new evaluation_1.Test();
|
|
29
|
-
test.verdict = verdict;
|
|
30
|
-
test.resultCode = resultCode;
|
|
31
|
-
this.addTestResult(test);
|
|
32
52
|
}
|
|
33
53
|
else {
|
|
34
54
|
verdict = evaluation_1.Verdict.FAILED;
|
|
35
55
|
resultCode = 'F2';
|
|
36
56
|
}
|
|
37
|
-
|
|
57
|
+
candidates.forEach((element) => {
|
|
38
58
|
const test = new evaluation_1.Test();
|
|
39
59
|
test.verdict = verdict;
|
|
40
60
|
test.resultCode = resultCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qualweb/best-practices",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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.
|
|
69
|
+
"@qualweb/core": "^0.8.9",
|
|
70
70
|
"@qualweb/locale": "0.2.2",
|
|
71
|
-
"@qualweb/qw-page": "0.3.
|
|
72
|
-
"@qualweb/util": "0.6.
|
|
71
|
+
"@qualweb/qw-page": "0.3.5",
|
|
72
|
+
"@qualweb/util": "0.6.5",
|
|
73
73
|
"@tsconfig/recommended": "^1.0.3",
|
|
74
74
|
"@types/mocha": "^10.0.6",
|
|
75
75
|
"@types/node": "^16.11.12",
|