Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deprecatedrole,color-contrast): fix message to properly include deprecated role, improve color-contrast pass messages #3387

Merged
merged 4 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checks/aria/deprecatedrole.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"impact": "minor",
"messages": {
"pass": "ARIA role is not deprecated",
"fail": "The role used is deprecated: ${data.values}"
"fail": "The role used is deprecated: ${data}"
}
}
}
2 changes: 2 additions & 0 deletions lib/checks/color/color-contrast-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function colorContrastEvaluate(node, options, virtualNode) {
} = options;

if (!isVisible(node, false)) {
this.data({ messageKey: 'hidden' });
return true;
}

Expand Down Expand Up @@ -97,6 +98,7 @@ export default function colorContrastEvaluate(node, options, virtualNode) {
(typeof minThreshold === 'number' && contrast < minThreshold) ||
(typeof maxThreshold === 'number' && contrast > maxThreshold)
) {
this.data({ contrastRatio: contrast });
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/checks/color/color-contrast.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"metadata": {
"impact": "serious",
"messages": {
"pass": "Element has sufficient color contrast of ${data.contrastRatio}",
"pass": {
"default": "Element has sufficient color contrast of ${data.contrastRatio}",
"hidden": "Element is hidden"
},
"fail": {
"default": "Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}",
"fgOnShadowColor": "Element has insufficient color contrast of ${data.contrastRatio} between the foreground and shadow color (foreground color: ${data.fgColor}, text-shadow color: ${data.shadowColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}",
Expand Down
25 changes: 25 additions & 0 deletions test/testutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,31 @@ testUtils.getCheckEvaluate = function getCheckEvaluate(checkId, testOptions) {
result +
noneCheckMessage
);

var message = axe.utils.processMessage(
messages[key][messageKey],
this._data
);
assert.isTrue(
message.indexOf('${') === -1,
'Data object missing properties for ' +
key +
' message key "' +
messageKey +
'": "' +
message +
'"'
);
} else {
var message = axe.utils.processMessage(messages[key], this._data);
assert.isTrue(
message.indexOf('${') === -1,
'Data object missing properties for ' +
key +
' message: "' +
message +
'"'
);
}
}

Expand Down