@qualweb/wcag-techniques
Version:
Implementation of the WCAG 2.1 techniques
77 lines (76 loc) • 3.49 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_T30 = 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_T30 extends Technique_object_1.Technique {
execute(element) {
const test = new evaluation_1.Test();
if (element.elementHasAttribute('qw-css-rules')) {
const cssRules = element.getCSSRules();
const property = this.findTextDecorationWithBlink(cssRules);
if (property !== undefined) {
test.verdict = evaluation_1.Verdict.FAILED;
test.resultCode = 'F1';
test.elements.push({
pointer: element.getElementSelector(),
htmlCode: element.getElementHtmlCode(true, true),
property: {
name: 'text-decoration',
value: 'blink'
},
stylesheetFile: property.pointer
});
this.addTestResult(test);
}
}
}
findTextDecorationWithBlink(properties) {
for (const property in properties !== null && properties !== void 0 ? properties : {}) {
if (properties === null || properties === void 0 ? void 0 : properties[property]) {
if (property === 'media') {
const mediaRule = this.findInMediaRules(properties.media);
if (mediaRule !== undefined) {
return mediaRule;
}
}
else if (property === 'text-decoration') {
if (properties[property].value === 'blink') {
return properties[property];
}
}
}
}
return undefined;
}
findInMediaRules(media) {
var _a;
for (const condition in media !== null && media !== void 0 ? media : {}) {
for (const property in (_a = media[condition]) !== null && _a !== void 0 ? _a : {}) {
if (property === 'text-decoration') {
if (media[condition][property]['value'] === 'blink') {
return media[condition][property];
}
}
}
}
return undefined;
}
}
exports.QW_WCAG_T30 = QW_WCAG_T30;
__decorate([
applicability_1.ElementExists,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Function]),
__metadata("design:returntype", void 0)
], QW_WCAG_T30.prototype, "execute", null);