@qualweb/best-practices 0.6.19 → 0.7.0
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.
- package/README.md +40 -0
- package/dist/BestPracticesModule.d.ts +10 -0
- package/dist/BestPracticesModule.d.ts.map +1 -0
- package/dist/BestPracticesModule.js +19 -0
- package/dist/BestPracticesRunner.d.ts +9 -0
- package/dist/BestPracticesRunner.d.ts.map +1 -0
- package/dist/BestPracticesRunner.js +17 -0
- package/dist/__webpack/bp.bundle.js +1 -0
- package/dist/best-practices/QW-BP1.d.ts +7 -0
- package/dist/best-practices/QW-BP1.d.ts.map +1 -0
- package/dist/best-practices/QW-BP1.js +37 -0
- package/dist/best-practices/QW-BP10.d.ts +7 -0
- package/dist/best-practices/QW-BP10.d.ts.map +1 -0
- package/dist/best-practices/QW-BP10.js +35 -0
- package/dist/best-practices/QW-BP11.d.ts +7 -0
- package/dist/best-practices/QW-BP11.d.ts.map +1 -0
- package/dist/best-practices/QW-BP11.js +52 -0
- package/dist/best-practices/QW-BP12.d.ts +7 -0
- package/dist/best-practices/QW-BP12.d.ts.map +1 -0
- package/dist/best-practices/QW-BP12.js +65 -0
- package/dist/best-practices/QW-BP13.d.ts +7 -0
- package/dist/best-practices/QW-BP13.d.ts.map +1 -0
- package/dist/best-practices/QW-BP13.js +47 -0
- package/dist/best-practices/QW-BP15.d.ts +8 -0
- package/dist/best-practices/QW-BP15.d.ts.map +1 -0
- package/dist/best-practices/QW-BP15.js +44 -0
- package/dist/best-practices/QW-BP17.d.ts +7 -0
- package/dist/best-practices/QW-BP17.d.ts.map +1 -0
- package/dist/best-practices/QW-BP17.js +26 -0
- package/dist/best-practices/QW-BP18.d.ts +11 -0
- package/dist/best-practices/QW-BP18.d.ts.map +1 -0
- package/dist/best-practices/QW-BP18.js +135 -0
- package/dist/best-practices/QW-BP19.d.ts +7 -0
- package/dist/best-practices/QW-BP19.d.ts.map +1 -0
- package/dist/best-practices/QW-BP19.js +39 -0
- package/dist/best-practices/QW-BP2.d.ts +7 -0
- package/dist/best-practices/QW-BP2.d.ts.map +1 -0
- package/dist/best-practices/QW-BP2.js +51 -0
- package/dist/best-practices/QW-BP20.d.ts +7 -0
- package/dist/best-practices/QW-BP20.d.ts.map +1 -0
- package/dist/best-practices/QW-BP20.js +41 -0
- package/dist/best-practices/QW-BP21.d.ts +7 -0
- package/dist/best-practices/QW-BP21.d.ts.map +1 -0
- package/dist/best-practices/QW-BP21.js +40 -0
- package/dist/best-practices/QW-BP22.d.ts +7 -0
- package/dist/best-practices/QW-BP22.d.ts.map +1 -0
- package/dist/best-practices/QW-BP22.js +40 -0
- package/dist/best-practices/QW-BP23.d.ts +7 -0
- package/dist/best-practices/QW-BP23.d.ts.map +1 -0
- package/dist/best-practices/QW-BP23.js +44 -0
- package/dist/best-practices/QW-BP24.d.ts +7 -0
- package/dist/best-practices/QW-BP24.d.ts.map +1 -0
- package/dist/best-practices/QW-BP24.js +47 -0
- package/dist/best-practices/QW-BP25.d.ts +7 -0
- package/dist/best-practices/QW-BP25.d.ts.map +1 -0
- package/dist/best-practices/QW-BP25.js +38 -0
- package/dist/best-practices/QW-BP26.d.ts +7 -0
- package/dist/best-practices/QW-BP26.d.ts.map +1 -0
- package/dist/best-practices/QW-BP26.js +38 -0
- package/dist/best-practices/QW-BP27.d.ts +7 -0
- package/dist/best-practices/QW-BP27.d.ts.map +1 -0
- package/dist/best-practices/QW-BP27.js +38 -0
- package/dist/best-practices/QW-BP28.d.ts +7 -0
- package/dist/best-practices/QW-BP28.d.ts.map +1 -0
- package/dist/best-practices/QW-BP28.js +38 -0
- package/dist/best-practices/QW-BP29.d.ts +7 -0
- package/dist/best-practices/QW-BP29.d.ts.map +1 -0
- package/dist/best-practices/QW-BP29.js +48 -0
- package/dist/best-practices/QW-BP4.d.ts +7 -0
- package/dist/best-practices/QW-BP4.d.ts.map +1 -0
- package/dist/best-practices/QW-BP4.js +35 -0
- package/dist/best-practices/QW-BP5.d.ts +7 -0
- package/dist/best-practices/QW-BP5.d.ts.map +1 -0
- package/dist/best-practices/QW-BP5.js +21 -0
- package/dist/best-practices/QW-BP6.d.ts +7 -0
- package/dist/best-practices/QW-BP6.d.ts.map +1 -0
- package/dist/best-practices/QW-BP6.js +38 -0
- package/dist/best-practices/QW-BP7.d.ts +7 -0
- package/dist/best-practices/QW-BP7.d.ts.map +1 -0
- package/dist/best-practices/QW-BP7.js +39 -0
- package/dist/best-practices/QW-BP8.d.ts +8 -0
- package/dist/best-practices/QW-BP8.d.ts.map +1 -0
- package/dist/best-practices/QW-BP8.js +71 -0
- package/dist/best-practices/QW-BP9.d.ts +7 -0
- package/dist/best-practices/QW-BP9.d.ts.map +1 -0
- package/dist/best-practices/QW-BP9.js +53 -0
- package/dist/best-practices/index.d.ts +27 -0
- package/dist/best-practices/index.d.ts.map +1 -0
- package/dist/best-practices/index.js +42 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/lib/BestPractice.object.d.ts +21 -0
- package/dist/lib/BestPractice.object.d.ts.map +1 -0
- package/dist/lib/BestPractice.object.js +76 -0
- package/dist/lib/BestPracticesTester.object.d.ts +8 -0
- package/dist/lib/BestPracticesTester.object.d.ts.map +1 -0
- package/dist/lib/BestPracticesTester.object.js +67 -0
- package/dist/lib/bestPractices.json +318 -0
- package/dist/lib/mapping.d.ts +24 -0
- package/dist/lib/mapping.d.ts.map +1 -0
- package/dist/lib/mapping.js +24 -0
- package/package.json +19 -17
- package/dist/bp.bundle.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP1.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP1.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,MAAO,SAAQ,YAAY;IAE/B,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAelC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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_BP1 = void 0;
|
|
13
|
+
const evaluation_1 = require("@qualweb/core/evaluation");
|
|
14
|
+
const applicability_1 = require("@qualweb/util/applicability");
|
|
15
|
+
const BestPractice_object_1 = require("../lib/BestPractice.object");
|
|
16
|
+
class QW_BP1 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
execute(element) {
|
|
18
|
+
const headings = element.getElements('h1, h2, h3, h4, h5, h6, [role="heading"]');
|
|
19
|
+
for (const heading of headings !== null && headings !== void 0 ? headings : []) {
|
|
20
|
+
if (window.AccessibilityUtils.isElementInAT(heading) || window.DomUtils.isElementVisible(heading)) {
|
|
21
|
+
const test = new evaluation_1.Test(evaluation_1.Verdict.WARNING, undefined, 'W1');
|
|
22
|
+
test.addElement(heading);
|
|
23
|
+
this.addTestResult(test);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (this.bestPractice.metadata.warning === 0) {
|
|
27
|
+
this.addTestResult(new evaluation_1.Test(evaluation_1.Verdict.FAILED, undefined, 'F1'));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.QW_BP1 = QW_BP1;
|
|
32
|
+
__decorate([
|
|
33
|
+
applicability_1.ElementExists,
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", [Function]),
|
|
36
|
+
__metadata("design:returntype", void 0)
|
|
37
|
+
], QW_BP1.prototype, "execute", null);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QWElement } from '@qualweb/qw-element';
|
|
2
|
+
import { BestPractice } from '../lib/BestPractice.object';
|
|
3
|
+
declare class QW_BP10 extends BestPractice {
|
|
4
|
+
execute(element?: QWElement): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export { QW_BP10 };
|
|
7
|
+
//# sourceMappingURL=QW-BP10.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP10.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP10.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAC1B,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBlD;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.QW_BP10 = void 0;
|
|
13
|
+
const evaluation_1 = require("@qualweb/core/evaluation");
|
|
14
|
+
const BestPractice_object_1 = require("../lib/BestPractice.object");
|
|
15
|
+
class QW_BP10 extends BestPractice_object_1.BestPractice {
|
|
16
|
+
execute(element) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const test = new evaluation_1.Test();
|
|
19
|
+
if (element === undefined) {
|
|
20
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
21
|
+
test.resultCode = 'P1';
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const name = element.getElementTagName();
|
|
25
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
26
|
+
test.description = this.translate('F1', { name });
|
|
27
|
+
test.resultCode = 'F1';
|
|
28
|
+
test.attributes.push(name);
|
|
29
|
+
test.addElement(element);
|
|
30
|
+
}
|
|
31
|
+
this.addTestResult(test);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.QW_BP10 = QW_BP10;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP11.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP11.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;CA6BlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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_BP11 = 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_BP11 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
execute(element) {
|
|
18
|
+
const test = new evaluation_1.Test();
|
|
19
|
+
let result = 0;
|
|
20
|
+
let hasBr = false;
|
|
21
|
+
for (const child of element.getElementChildren() || []) {
|
|
22
|
+
const type = child.getElementType();
|
|
23
|
+
if (child && child.getElementTagName() === 'br') {
|
|
24
|
+
result++;
|
|
25
|
+
hasBr = true;
|
|
26
|
+
}
|
|
27
|
+
else if (type !== 'text') {
|
|
28
|
+
result = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (hasBr && result <= 3) {
|
|
32
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
33
|
+
test.resultCode = 'P1';
|
|
34
|
+
}
|
|
35
|
+
else if (hasBr) {
|
|
36
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
37
|
+
test.resultCode = 'F1';
|
|
38
|
+
}
|
|
39
|
+
if (hasBr) {
|
|
40
|
+
test.addElement(element);
|
|
41
|
+
this.addTestResult(test);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.QW_BP11 = QW_BP11;
|
|
46
|
+
__decorate([
|
|
47
|
+
applicability_1.ElementExists,
|
|
48
|
+
(0, applicability_1.ElementHasChild)('*'),
|
|
49
|
+
__metadata("design:type", Function),
|
|
50
|
+
__metadata("design:paramtypes", [Function]),
|
|
51
|
+
__metadata("design:returntype", void 0)
|
|
52
|
+
], QW_BP11.prototype, "execute", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP12.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP12.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAGhC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CA8ClC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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_BP12 = void 0;
|
|
13
|
+
const qw_element_1 = require("@qualweb/qw-element");
|
|
14
|
+
const applicability_1 = require("@qualweb/util/applicability");
|
|
15
|
+
const evaluation_1 = require("@qualweb/core/evaluation");
|
|
16
|
+
const BestPractice_object_1 = require("../lib/BestPractice.object");
|
|
17
|
+
class QW_BP12 extends BestPractice_object_1.BestPractice {
|
|
18
|
+
execute(element) {
|
|
19
|
+
const rows = element.getElements('tr');
|
|
20
|
+
let firstRowChildren = [];
|
|
21
|
+
if (rows.length > 0) {
|
|
22
|
+
firstRowChildren = rows[0].getElementChildren();
|
|
23
|
+
let i, scope;
|
|
24
|
+
let scopeCole = true;
|
|
25
|
+
for (i = 1; i < firstRowChildren.length; i++) {
|
|
26
|
+
if (firstRowChildren[i].getElementTagName() === 'td' ||
|
|
27
|
+
(firstRowChildren[i].getElementTagName() === 'th' && scopeCole)) {
|
|
28
|
+
scope = firstRowChildren[i].getElementAttribute('scope');
|
|
29
|
+
scopeCole = scope === 'col';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let scopeRow = true;
|
|
33
|
+
let row;
|
|
34
|
+
for (i = 1; i < rows.length; i++) {
|
|
35
|
+
if (scopeRow) {
|
|
36
|
+
row = rows[i];
|
|
37
|
+
const cells = row.getElements('td');
|
|
38
|
+
if (cells.length > 0) {
|
|
39
|
+
scope = cells[0].getElementAttribute('scope');
|
|
40
|
+
scopeRow = scope === 'row';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const test = new evaluation_1.Test();
|
|
45
|
+
if (scopeCole && scopeRow) {
|
|
46
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
47
|
+
test.resultCode = 'P1';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
51
|
+
test.resultCode = 'F1';
|
|
52
|
+
}
|
|
53
|
+
test.addElement(element);
|
|
54
|
+
this.addTestResult(test);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.QW_BP12 = QW_BP12;
|
|
59
|
+
__decorate([
|
|
60
|
+
applicability_1.ElementExists,
|
|
61
|
+
(0, applicability_1.ElementHasChild)('tr'),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [qw_element_1.QWElement]),
|
|
64
|
+
__metadata("design:returntype", void 0)
|
|
65
|
+
], QW_BP12.prototype, "execute", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP13.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP13.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;IAEhC,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CA6BlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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_BP13 = 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_BP13 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
execute(element) {
|
|
18
|
+
const aWithImg = element.getElementParent();
|
|
19
|
+
if (!aWithImg) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const test = new evaluation_1.Test();
|
|
23
|
+
const href = aWithImg.getElementAttribute('href');
|
|
24
|
+
const aWithImgNext = aWithImg.getElementNextSibling();
|
|
25
|
+
const aWithImgPrev = aWithImg.getElementPreviousSibling();
|
|
26
|
+
if ((aWithImgNext && aWithImgNext.getElementAttribute('href') === href) ||
|
|
27
|
+
(aWithImgPrev && aWithImgPrev.getElementAttribute('href') === href)) {
|
|
28
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
29
|
+
test.resultCode = 'F1';
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
33
|
+
test.resultCode = 'P1';
|
|
34
|
+
}
|
|
35
|
+
if (aWithImg.getElementParent()) {
|
|
36
|
+
test.addElement(element);
|
|
37
|
+
}
|
|
38
|
+
this.addTestResult(test);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.QW_BP13 = QW_BP13;
|
|
42
|
+
__decorate([
|
|
43
|
+
applicability_1.ElementExists,
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", [Function]),
|
|
46
|
+
__metadata("design:returntype", void 0)
|
|
47
|
+
], QW_BP13.prototype, "execute", null);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QWElement } from '@qualweb/qw-element';
|
|
2
|
+
import { BestPractice } from '../lib/BestPractice.object';
|
|
3
|
+
declare class QW_BP15 extends BestPractice {
|
|
4
|
+
private readonly absoluteLengths;
|
|
5
|
+
execute(element: QWElement): void;
|
|
6
|
+
}
|
|
7
|
+
export { QW_BP15 };
|
|
8
|
+
//# sourceMappingURL=QW-BP15.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP15.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP15.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,eAAe,CAAwC;IAIxE,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;CAiBlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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_BP15 = 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_BP15 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.absoluteLengths = ['cm', 'mm', 'in', 'px', 'pt', 'pc'];
|
|
20
|
+
}
|
|
21
|
+
execute(element) {
|
|
22
|
+
const test = new evaluation_1.Test();
|
|
23
|
+
const width = element.getElementAttribute('width');
|
|
24
|
+
const unit = width.trim().substring(width.length - 2, width.length);
|
|
25
|
+
if (!this.absoluteLengths.includes(unit) && parseFloat(width).toString().length !== width.length) {
|
|
26
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
27
|
+
test.resultCode = 'P1';
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
31
|
+
test.resultCode = 'F1';
|
|
32
|
+
}
|
|
33
|
+
test.addElement(element);
|
|
34
|
+
this.addTestResult(test);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.QW_BP15 = QW_BP15;
|
|
38
|
+
__decorate([
|
|
39
|
+
applicability_1.ElementExists,
|
|
40
|
+
applicability_1.ElementIsVisible,
|
|
41
|
+
__metadata("design:type", Function),
|
|
42
|
+
__metadata("design:paramtypes", [Function]),
|
|
43
|
+
__metadata("design:returntype", void 0)
|
|
44
|
+
], QW_BP15.prototype, "execute", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP17.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP17.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,OAAQ,SAAQ,YAAY;IAChC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI;CAoBnC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QW_BP17 = void 0;
|
|
4
|
+
const evaluation_1 = require("@qualweb/core/evaluation");
|
|
5
|
+
const BestPractice_object_1 = require("../lib/BestPractice.object");
|
|
6
|
+
class QW_BP17 extends BestPractice_object_1.BestPractice {
|
|
7
|
+
execute(element) {
|
|
8
|
+
const test = new evaluation_1.Test();
|
|
9
|
+
if (!element) {
|
|
10
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
11
|
+
test.resultCode = 'F1';
|
|
12
|
+
this.addTestResult(test);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const refElement = window.DomUtils.getElementReferencedByHREF(element);
|
|
16
|
+
if (refElement) {
|
|
17
|
+
test.verdict = evaluation_1.Verdict.WARNING;
|
|
18
|
+
test.resultCode = 'W1';
|
|
19
|
+
test.addElement(element);
|
|
20
|
+
test.addElement(refElement);
|
|
21
|
+
this.addTestResult(test);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.QW_BP17 = QW_BP17;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { QWElement } from '@qualweb/qw-element';
|
|
2
|
+
import { BestPractice } from '../lib/BestPractice.object';
|
|
3
|
+
declare class QW_BP18 extends BestPractice {
|
|
4
|
+
private readonly containers;
|
|
5
|
+
execute(element: QWElement): void;
|
|
6
|
+
private checkIfCssSelectorIsApplicable;
|
|
7
|
+
private checkCssProperty;
|
|
8
|
+
private hasContainers;
|
|
9
|
+
}
|
|
10
|
+
export { QW_BP18 };
|
|
11
|
+
//# sourceMappingURL=QW-BP18.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP18.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP18.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,UAAU,CA2BzB;IAGF,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI;IAkBjC,OAAO,CAAC,8BAA8B;IA0BtC,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,aAAa;CAatB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
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_BP18 = 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_BP18 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.containers = [
|
|
20
|
+
'span',
|
|
21
|
+
'article',
|
|
22
|
+
'section',
|
|
23
|
+
'nav',
|
|
24
|
+
'aside',
|
|
25
|
+
'hgroup',
|
|
26
|
+
'header',
|
|
27
|
+
'footer',
|
|
28
|
+
'address',
|
|
29
|
+
'p',
|
|
30
|
+
'hr',
|
|
31
|
+
'blockquote',
|
|
32
|
+
'div',
|
|
33
|
+
'h1',
|
|
34
|
+
'h2',
|
|
35
|
+
'h3',
|
|
36
|
+
'h4',
|
|
37
|
+
'h5',
|
|
38
|
+
'h6',
|
|
39
|
+
'li',
|
|
40
|
+
'ul',
|
|
41
|
+
'ol',
|
|
42
|
+
'dd',
|
|
43
|
+
'dt',
|
|
44
|
+
'dl',
|
|
45
|
+
'figcaption'
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
execute(element) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
if (element.getElementTagName() === 'style') {
|
|
51
|
+
const sheet = element.getElementProperty('sheet');
|
|
52
|
+
for (const rule of sheet.cssRules || []) {
|
|
53
|
+
if (((_b = (_a = rule === null || rule === void 0 ? void 0 : rule.style) === null || _a === void 0 ? void 0 : _a.cssText) === null || _b === void 0 ? void 0 : _b.includes('width:')) && this.checkIfCssSelectorIsApplicable(rule)) {
|
|
54
|
+
const style = (_c = rule === null || rule === void 0 ? void 0 : rule.style) === null || _c === void 0 ? void 0 : _c.cssText;
|
|
55
|
+
if (style) {
|
|
56
|
+
this.checkCssProperty(style, element);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const style = element.getElementAttribute('style');
|
|
63
|
+
this.checkCssProperty(style, element);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
checkIfCssSelectorIsApplicable(rule) {
|
|
67
|
+
const selectors = rule.selectorText
|
|
68
|
+
.split(new RegExp(/(?![^)(]*\([^)(]*?\)\)),(?![^\(]*\))/gm))
|
|
69
|
+
.map((s) => s.trim()) || [rule.selectorText.trim()];
|
|
70
|
+
const hasContainers = this.hasContainers(selectors);
|
|
71
|
+
if (hasContainers.length > 0) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
let affectsContainers = false;
|
|
75
|
+
for (const selector of selectors || []) {
|
|
76
|
+
if (selector.startsWith('.') || selector.startsWith('#')) {
|
|
77
|
+
const elements = window.qwPage.getElements(selector);
|
|
78
|
+
for (const element of elements || []) {
|
|
79
|
+
if (this.containers.includes(element.getElementTagName())) {
|
|
80
|
+
affectsContainers = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return affectsContainers;
|
|
87
|
+
}
|
|
88
|
+
checkCssProperty(style, element) {
|
|
89
|
+
const test = new evaluation_1.Test();
|
|
90
|
+
const properties = style.split(';').filter((p) => p.trim() !== '') || [style];
|
|
91
|
+
for (const property of properties || []) {
|
|
92
|
+
if (property === null || property === void 0 ? void 0 : property.includes('width')) {
|
|
93
|
+
const width = property.split(':')[1];
|
|
94
|
+
const hasImportant = width === null || width === void 0 ? void 0 : width.includes('!important');
|
|
95
|
+
if (hasImportant) {
|
|
96
|
+
if (width.endsWith('%')) {
|
|
97
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
98
|
+
test.resultCode = 'P1';
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
102
|
+
if (width.endsWith('px')) {
|
|
103
|
+
test.resultCode = 'F1';
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
test.resultCode = 'F2';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
test.attributes.push(property);
|
|
110
|
+
test.addElement(element);
|
|
111
|
+
this.addTestResult(test);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
hasContainers(selectors) {
|
|
117
|
+
var _a;
|
|
118
|
+
const common = new Array();
|
|
119
|
+
for (const selector of selectors !== null && selectors !== void 0 ? selectors : []) {
|
|
120
|
+
for (const container of (_a = this.containers) !== null && _a !== void 0 ? _a : []) {
|
|
121
|
+
if (selector === container) {
|
|
122
|
+
common.push(selector);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return common;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.QW_BP18 = QW_BP18;
|
|
130
|
+
__decorate([
|
|
131
|
+
applicability_1.ElementExists,
|
|
132
|
+
__metadata("design:type", Function),
|
|
133
|
+
__metadata("design:paramtypes", [Function]),
|
|
134
|
+
__metadata("design:returntype", void 0)
|
|
135
|
+
], QW_BP18.prototype, "execute", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP19.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP19.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;CAclC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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_BP19 = 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_BP19 extends BestPractice_object_1.BestPractice {
|
|
17
|
+
execute(element) {
|
|
18
|
+
const test = new evaluation_1.Test();
|
|
19
|
+
const isTopLevel = window.AccessibilityUtils.landmarkIsTopLevel(element);
|
|
20
|
+
if (isTopLevel) {
|
|
21
|
+
test.verdict = evaluation_1.Verdict.PASSED;
|
|
22
|
+
test.resultCode = 'P1';
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
test.verdict = evaluation_1.Verdict.FAILED;
|
|
26
|
+
test.resultCode = 'F1';
|
|
27
|
+
}
|
|
28
|
+
test.addElement(element);
|
|
29
|
+
this.addTestResult(test);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.QW_BP19 = QW_BP19;
|
|
33
|
+
__decorate([
|
|
34
|
+
applicability_1.ElementExists,
|
|
35
|
+
(0, applicability_1.ElementHasAttributeRole)('banner'),
|
|
36
|
+
__metadata("design:type", Function),
|
|
37
|
+
__metadata("design:paramtypes", [Function]),
|
|
38
|
+
__metadata("design:returntype", void 0)
|
|
39
|
+
], QW_BP19.prototype, "execute", null);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QWElement } from '@qualweb/qw-element';
|
|
2
|
+
import { BestPractice } from '../lib/BestPractice.object';
|
|
3
|
+
declare class QW_BP2 extends BestPractice {
|
|
4
|
+
execute(element: QWElement): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export { QW_BP2 };
|
|
7
|
+
//# sourceMappingURL=QW-BP2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QW-BP2.d.ts","sourceRoot":"","sources":["../../src/best-practices/QW-BP2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,cAAM,MAAO,SAAQ,YAAY;IAIzB,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBjD;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|