@qualweb/wcag-techniques
Version:
Implementation of the WCAG 2.1 techniques
55 lines (54 loc) • 2.67 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QW_WCAG_T8 = void 0;
const applicability_1 = require("@qualweb/util/applicability");
const evaluation_1 = require("@qualweb/core/evaluation");
const Technique_object_1 = require("../lib/Technique.object");
class QW_WCAG_T8 extends Technique_object_1.Technique {
constructor() {
super(...arguments);
this.default_title = ['spacer', 'image', 'picture', 'separador', 'imagem', 'fotografia'];
this.pattern = new RegExp('.+\\.(jpg|jpeg|png|gif|tiff|bmp)');
this.pattern1 = new RegExp('^picture\\s[0-9]+$');
this.pattern2 = new RegExp('^[0-9]+$');
this.pattern3 = new RegExp('^intro#[0-9]+$');
this.pattern4 = new RegExp('^imagem\\s[0-9]+$');
}
execute(element) {
const test = new evaluation_1.Test();
const accessibleName = window.AccessibilityUtils.getAccessibleName(element).toLocaleLowerCase();
if (!this.pattern4.test(accessibleName) &&
!this.pattern3.test(accessibleName) &&
!this.pattern2.test(accessibleName) &&
!this.pattern1.test(accessibleName) &&
!this.pattern.test(accessibleName) &&
!this.default_title.includes(accessibleName)) {
test.verdict = evaluation_1.Verdict.WARNING;
test.resultCode = 'W1';
}
else {
test.verdict = evaluation_1.Verdict.FAILED;
test.resultCode = 'F1';
}
test.addElement(element);
this.addTestResult(test);
}
}
exports.QW_WCAG_T8 = QW_WCAG_T8;
__decorate([
applicability_1.ElementExists,
applicability_1.ElementHasAttributes,
applicability_1.ElementHasAccessibleName,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Function]),
__metadata("design:returntype", void 0)
], QW_WCAG_T8.prototype, "execute", null);