Skip to content

Commit

Permalink
Merge pull request #32 from qualweb/contrast-fix
Browse files Browse the repository at this point in the history
Contrast rules applicability fix
  • Loading branch information
AntonioEstriga authored Oct 17, 2023
2 parents 985815b + 7ef6a38 commit 90f49ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qualweb/act-rules",
"version": "0.6.16",
"version": "0.6.17",
"description": "ACT rules module for qualweb web accessibility evaluator",
"main": "dist/act.bundle.js",
"files": [
Expand Down
16 changes: 6 additions & 10 deletions src/rules/QW-ACT-R37.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
ElementHasText,
ElementIsHTMLElement,
ElementIsNot,
ElementIsVisible,
ElementIsNotWidget
ElementIsVisible
} from '../lib/decorator';
import Test from '../lib/Test.object';

Expand All @@ -22,7 +21,6 @@ class QW_ACT_R37 extends AtomicRule {
@ElementIsHTMLElement
@ElementIsNot(['html', 'head', 'body', 'script', 'style', 'meta'])
@ElementIsVisible
@ElementIsNotWidget
@ElementHasText
execute(element: typeof window.qwElement): void {
const disabledWidgets = window.disabledWidgets;
Expand All @@ -47,18 +45,16 @@ class QW_ACT_R37 extends AtomicRule {
return;
}

const isWidget = window.AccessibilityUtils.isElementWidget(element);
if (isWidget) {
return;
}

const elementSelectors = element.getElementSelector();

for (const disableWidget of disabledWidgets || []) {
const selectors = window.AccessibilityUtils.getAccessibleNameSelector(disableWidget);
if (disableWidget && selectors && selectors.includes(elementSelectors)) {
return;
}
if (disableWidget.getElementSelector() === elementSelectors) {
return;
}
}

const role = window.AccessibilityUtils.getElementRole(element);
Expand Down Expand Up @@ -288,7 +284,7 @@ class QW_ACT_R37 extends AtomicRule {
): boolean {
if (parsedGradientString.startsWith('linear-gradient')) {
const gradientDirection = this.getGradientDirection(parsedGradientString);
if (gradientDirection === 'to right') {
if (gradientDirection === 'to do') {
const colors = this.parseGradientString(parsedGradientString, opacity);
let isValid = true;
let contrastRatio;
Expand Down Expand Up @@ -320,7 +316,7 @@ class QW_ACT_R37 extends AtomicRule {
test.verdict = 'failed';
test.resultCode = 'F2';
}
} else if (gradientDirection === 'to left') {
} else if (gradientDirection === 'to left' || gradientDirection === 'to right') {
//TODO
test.verdict = 'warning';
test.resultCode = 'W3';
Expand Down
12 changes: 4 additions & 8 deletions src/rules/QW-ACT-R76.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
ElementHasText,
ElementIsHTMLElement,
ElementIsNot,
ElementIsVisible,
ElementIsNotWidget
ElementIsVisible
} from '../lib/decorator';
import Test from '../lib/Test.object';

Expand All @@ -22,7 +21,6 @@ class QW_ACT_R76 extends AtomicRule {
@ElementIsHTMLElement
@ElementIsNot(['html', 'head', 'body', 'script', 'style', 'meta'])
@ElementIsVisible
@ElementIsNotWidget
@ElementHasText
execute(element: typeof window.qwElement): void {
const disabledWidgets = window.disabledWidgets;
Expand All @@ -47,18 +45,16 @@ class QW_ACT_R76 extends AtomicRule {
return;
}

const isWidget = window.AccessibilityUtils.isElementWidget(element);
if (isWidget) {
return;
}

const elementSelectors = element.getElementSelector();

for (const disableWidget of disabledWidgets || []) {
const selectors = window.AccessibilityUtils.getAccessibleNameSelector(disableWidget);
if (disableWidget && selectors && selectors.includes(elementSelectors)) {
return;
}
if (disableWidget.getElementSelector() === elementSelectors) {
return;
}
}

const role = window.AccessibilityUtils.getElementRole(element);
Expand Down

0 comments on commit 90f49ec

Please sign in to comment.