UNPKG

@qualweb/act-rules

Version:

ACT rules module for qualweb web accessibility evaluator

99 lines (98 loc) 4.64 kB
"use strict"; 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_ACT_R43 = void 0; const applicability_1 = require("@qualweb/util/applicability"); const evaluation_1 = require("@qualweb/core/evaluation"); const AtomicRule_object_1 = require("../lib/AtomicRule.object"); class QW_ACT_R43 extends AtomicRule_object_1.AtomicRule { execute(element) { if (element.getElementTagName().toLowerCase() === 'iframe') { return; } let hasVisibleChildren = false; let isApplicable = false; for (const child of element.getElementChildren()) { if (window.DomUtils.isElementVisible(child)) { hasVisibleChildren = true; break; } } if (hasVisibleChildren) { const of = element.getElementStyleProperty('overflow', null); const ofx = element.getElementStyleProperty('overflow-x', null); const ofy = element.getElementStyleProperty('overflow-y', null); if (of === 'auto' || of === 'clip' || of === 'scroll' || ofx === 'auto' || ofx === 'clip' || ofx === 'scroll' || ofy === 'auto' || ofy === 'clip' || ofy === 'scroll') { const scrollWidth = element.getElementProperty('scrollWidth'); const clientWidth = element.getElementProperty('clientWidth'); const differenceWidth = parseInt(scrollWidth) - parseInt(clientWidth); const scrollHeight = element.getElementProperty('scrollHeight'); const clientHeight = element.getElementProperty('clientHeight'); const differenceHeight = parseInt(scrollHeight) - parseInt(clientHeight); const paddingLeft = element.getElementStyleProperty('padding-left', null); const paddingRight = element.getElementStyleProperty('padding-right', null); const paddingTop = element.getElementStyleProperty('padding-top', null); const paddingBottom = element.getElementStyleProperty('padding-bottom', null); isApplicable = differenceWidth > parseInt(paddingLeft) || differenceWidth > parseInt(paddingRight) || differenceHeight > parseInt(paddingTop) || differenceHeight > parseInt(paddingBottom); } } if (isApplicable) { const test = new evaluation_1.Test(); if (this.isInSequentialFocusNavigation(element)) { test.verdict = evaluation_1.Verdict.PASSED; test.resultCode = 'P1'; } else { test.verdict = evaluation_1.Verdict.FAILED; test.resultCode = 'F1'; } test.addElement(element); this.addTestResult(test); } } isInSequentialFocusNavigation(element) { if (window.AccessibilityUtils.isPartOfSequentialFocusNavigation(element)) { return true; } else { let result = false; for (const child of element.getElementChildren()) { if (window.AccessibilityUtils.isPartOfSequentialFocusNavigation(child)) { return true; } else { result = result || this.isInSequentialFocusNavigation(child); } } return result; } } } exports.QW_ACT_R43 = QW_ACT_R43; __decorate([ applicability_1.ElementExists, applicability_1.ElementIsVisible, __metadata("design:type", Function), __metadata("design:paramtypes", [Function]), __metadata("design:returntype", void 0) ], QW_ACT_R43.prototype, "execute", null);