Skip to content

Commit 11f259d

Browse files
committed
Added reviewPayload and updated metadata
1 parent c6cdc46 commit 11f259d

10 files changed

Lines changed: 86 additions & 13 deletions

build/tasks/validate.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ function createSchemas() {
227227
description: {
228228
required: true,
229229
type: 'string'
230+
},
231+
violationConfidence: {
232+
type: 'number',
233+
},
234+
needsReviewConfidence: {
235+
type: 'number',
236+
},
237+
defaultCategory: {
238+
type: 'string',
230239
}
231240
}
232241
}

lib/checks/aria/aria-prohibited-attr-evaluate.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ export default function ariaProhibitedAttrEvaluate(
5959

6060
let messageKey = role !== null ? 'hasRole' : 'noRole';
6161
messageKey += prohibited.length > 1 ? 'Plural' : 'Singular';
62-
this.data({ role, nodeName, messageKey, prohibited });
62+
// a11y-rule-aria-prohibited-attr: Add reviewPayload with accessible name from prohibited attr value
63+
const accessibleName =
64+
axe.commons.text.accessibleText(node)
65+
this.data({
66+
role,
67+
nodeName,
68+
messageKey,
69+
prohibited,
70+
reviewPayload: { visualHelperData: { accessibleName } }
71+
});
6372

6473
// `subtreeDescendant` to override namedFromContents
6574
const textContent = subtreeText(virtualNode, { subtreeDescendant: true });

lib/checks/color/color-contrast-evaluate.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,16 @@ export default function colorContrastEvaluate(node, options, virtualNode) {
148148
fontWeight: bold ? 'bold' : 'normal',
149149
messageKey: missing,
150150
expectedContrastRatio: expected + ':1',
151-
shadowColor: shadowColor ? shadowColor.toHexString() : undefined
151+
shadowColor: shadowColor ? shadowColor.toHexString() : undefined,
152+
// a11y-rule-color-contrast: reviewPayload for bulk NR visual helper (violation and needs-review)
153+
reviewPayload: {
154+
visualHelperData: {
155+
fgColor: fgColor ? fgColor.toHexString() : null,
156+
bgColor: bgColor ? bgColor.toHexString() : null,
157+
isLargeText: !isSmallFont,
158+
textContent: visibleText ? visibleText.slice(0, 100) : null
159+
}
160+
}
152161
});
153162

154163
// We don't know, so we'll put it into Can't Tell

lib/checks/label/label-content-name-mismatch-evaluate.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,29 @@ function labelContentNameMismatchEvaluate(node, options, virtualNode) {
140140
isHumanInterpretable(accText) < 1 ||
141141
isHumanInterpretable(visibleText) < 1
142142
) {
143+
// a11y-rule-label-content-name-mismatch: reviewPayload for NR accessible name display
144+
this.data({
145+
reviewPayload: {
146+
visualHelperData: {
147+
accessibleName: accText
148+
}
149+
}
150+
});
143151
return undefined;
144152
}
145153

146-
return isStringContained(visibleText, accText);
154+
const result = isStringContained(visibleText, accText);
155+
if (!result) {
156+
// a11y-rule-label-content-name-mismatch: reviewPayload for violation accessible name display
157+
this.data({
158+
reviewPayload: {
159+
visualHelperData: {
160+
accessibleName: accText
161+
}
162+
}
163+
});
164+
}
165+
return result;
147166
}
148167

149168
export default labelContentNameMismatchEvaluate;

lib/rules/aria-prohibited-attr.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"actIds": ["5c01ea"],
1515
"metadata": {
1616
"description": "Ensure ARIA attributes are not prohibited for an element's role",
17-
"help": "Elements must only use permitted ARIA attributes"
17+
"help": "Elements must only use permitted ARIA attributes",
18+
"violationConfidence": 90,
19+
"needsReviewConfidence": 60,
20+
"defaultCategory": "names-and-labels"
1821
},
1922
"all": [],
2023
"any": [],

lib/rules/color-contrast-enhanced.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"actIds": ["09o5cg"],
99
"metadata": {
1010
"description": "Ensure the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds",
11-
"help": "Elements must meet enhanced color contrast ratio thresholds"
11+
"help": "Elements must meet enhanced color contrast ratio thresholds",
12+
"needsReviewConfidence": 50,
13+
"defaultCategory": "text-contrast-enhanced"
1214
},
1315
"all": [],
1416
"any": ["color-contrast-enhanced"],

lib/rules/color-contrast.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"actIds": ["afw4f7", "09o5cg"],
1919
"metadata": {
2020
"description": "Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds",
21-
"help": "Elements must meet minimum color contrast ratio thresholds"
21+
"help": "Elements must meet minimum color contrast ratio thresholds",
22+
"needsReviewConfidence": 50,
23+
"defaultCategory": "text-contrast"
2224
},
2325
"all": [],
2426
"any": ["color-contrast"],

lib/rules/label-content-name-mismatch.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"actIds": ["2ee8b8"],
1818
"metadata": {
1919
"description": "Ensure that elements labelled through their content must have their visible text as part of their accessible name",
20-
"help": "Elements must have their visible text as part of their accessible name"
20+
"help": "Elements must have their visible text as part of their accessible name",
21+
"violationConfidence": 80,
22+
"needsReviewConfidence": 50,
23+
"defaultCategory": "names-and-labels"
2124
},
2225
"all": [],
2326
"any": ["label-content-name-mismatch"],

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
],
1818
"metadata": {
1919
"description": "Ensure links are distinguished from surrounding text in a way that does not rely on color",
20-
"help": "Links must be distinguishable without relying on color"
20+
"help": "Links must be distinguishable without relying on color",
21+
"needsReviewConfidence": 50,
22+
"defaultCategory": "links"
2123
},
2224
"any": ["link-in-text-block", "link-in-text-block-style"],
2325
"all": [

locales/_template.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959
},
6060
"aria-prohibited-attr": {
6161
"description": "Ensure ARIA attributes are not prohibited for an element's role",
62-
"help": "Elements must only use permitted ARIA attributes"
62+
"help": "Elements must only use permitted ARIA attributes",
63+
"violationConfidence": 90,
64+
"needsReviewConfidence": 60,
65+
"defaultCategory": "names-and-labels"
6366
},
6467
"aria-required-attr": {
6568
"description": "Ensure elements with ARIA roles have all required ARIA attributes",
@@ -131,11 +134,17 @@
131134
},
132135
"color-contrast-enhanced": {
133136
"description": "Ensure the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds",
134-
"help": "Elements must meet enhanced color contrast ratio thresholds"
137+
"help": "Elements must meet enhanced color contrast ratio thresholds",
138+
"violationConfidence": 90,
139+
"needsReviewConfidence": 60,
140+
"defaultCategory": "text-contrast-enhanced"
135141
},
136142
"color-contrast": {
137143
"description": "Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds",
138-
"help": "Elements must meet minimum color contrast ratio thresholds"
144+
"help": "Elements must meet minimum color contrast ratio thresholds",
145+
"violationConfidence": 90,
146+
"needsReviewConfidence": 60,
147+
"defaultCategory": "text-contrast"
139148
},
140149
"css-orientation-lock": {
141150
"description": "Ensure content is not locked to any specific display orientation, and the content is operable in all display orientations",
@@ -243,7 +252,10 @@
243252
},
244253
"label-content-name-mismatch": {
245254
"description": "Ensure that elements labelled through their content must have their visible text as part of their accessible name",
246-
"help": "Elements must have their visible text as part of their accessible name"
255+
"help": "Elements must have their visible text as part of their accessible name",
256+
"violationConfidence": 90,
257+
"needsReviewConfidence": 60,
258+
"defaultCategory": "names-and-labels"
247259
},
248260
"label-title-only": {
249261
"description": "Ensure that every form element has a visible label and is not solely labeled using hidden labels, or the title or aria-describedby attributes",
@@ -291,7 +303,10 @@
291303
},
292304
"link-in-text-block": {
293305
"description": "Ensure links are distinguished from surrounding text in a way that does not rely on color",
294-
"help": "Links must be distinguishable without relying on color"
306+
"help": "Links must be distinguishable without relying on color",
307+
"violationConfidence": 90,
308+
"needsReviewConfidence": 60,
309+
"defaultCategory": "links"
295310
},
296311
"link-name": {
297312
"description": "Ensure links have discernible text",

0 commit comments

Comments
 (0)