Skip to content

Commit 9ba67b7

Browse files
committed
Changed a11y_engine_commons variable name to a11yEngineCommons
2 parents 65746e5 + c5c8e34 commit 9ba67b7

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

lib/checks/color/link-in-text-block-evaluate.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getBackgroundColor,
55
incompleteData
66
} from '../../commons/color';
7+
import a11yEngineCommons from '../../commons/a11y-engine-index';
78

89
function getContrast(color1, color2) {
910
var c1lum = color1.getRelativeLuminance();
@@ -26,6 +27,8 @@ function isBlock(elm) {
2627

2728
function linkInTextBlockEvaluate(node, options) {
2829
const { requiredContrastRatio, allowSameColor } = options;
30+
var evaluateOptions =
31+
arguments.length > 1 && arguments[1] ? arguments[1] : {};
2932

3033
if (isBlock(node)) {
3134
return false;
@@ -42,6 +45,10 @@ function linkInTextBlockEvaluate(node, options) {
4245

4346
this.relatedNodes([parentBlock]);
4447

48+
if (evaluateOptions.a11yRule) {
49+
return a11yEngineCommons.distinguishableLinkEvaluate(node, parentBlock);
50+
}
51+
4552
// Capture colors
4653
var nodeColor = getForegroundColor(node);
4754
var parentColor = getForegroundColor(parentBlock);
@@ -116,4 +123,18 @@ function linkInTextBlockEvaluate(node, options) {
116123
return false;
117124
}
118125

126+
function getColorContrast(node, parentBlock) {
127+
// Check if contrast of foreground is sufficient
128+
var nodeColor, parentColor;
129+
nodeColor = getForegroundColor(node);
130+
parentColor = getForegroundColor(parentBlock);
131+
132+
if (!nodeColor || !parentColor) {
133+
return undefined;
134+
}
135+
136+
return getContrast(nodeColor, parentColor);
137+
}
138+
119139
export default linkInTextBlockEvaluate;
140+
export { getContrast, getColorContrast };

lib/checks/color/link-in-text-block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"evaluate": "link-in-text-block-evaluate",
44
"options": {
55
"requiredContrastRatio": 3,
6-
"allowSameColor": true
6+
"allowSameColor": true,
7+
"a11yRule": false
78
},
89
"metadata": {
910
"impact": "serious",

lib/commons/a11y-engine-index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { distinguishableLinkEvaluate } from '../../../a11y-engine-core/lib/commons/distinguishable-link';
2+
3+
const a11yEngineCommons = {};
4+
a11yEngineCommons.distinguishableLinkEvaluate = distinguishableLinkEvaluate;
5+
6+
export default a11yEngineCommons;

lib/rules/link-in-text-block.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
"description": "Ensure links are distinguished from surrounding text in a way that does not rely on color",
1818
"help": "Links must be distinguishable without relying on color"
1919
},
20-
"all": [],
2120
"any": ["link-in-text-block", "link-in-text-block-style"],
21+
"all": [
22+
{
23+
"options": {
24+
"a11yRule": false
25+
},
26+
"id": "link-in-text-block"
27+
}
28+
],
2229
"none": []
2330
}

0 commit comments

Comments
 (0)