Skip to content

Commit a1eed77

Browse files
authored
Merge pull request #114 from browserstack/release-3.4.0
release-3.4.0
2 parents 4334d1a + 1be13b9 commit a1eed77

File tree

7 files changed

+66
-2
lines changed

7 files changed

+66
-2
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ function getColorContrast(node, parentBlock) {
136136
nodeColor = getForegroundColor(node);
137137
parentColor = getForegroundColor(parentBlock);
138138

139+
if (!nodeColor) {
140+
nodeColor = new axe.commons.color.Color(0, 0, 0, 0);
141+
}
142+
143+
if (!parentColor) {
144+
parentColor = new axe.commons.color.Color(0, 0, 0, 0);
145+
}
146+
139147
if (!nodeColor || !parentColor) {
140148
return undefined;
141149
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Get the accessible name based on aria-describedby
3+
*
4+
* @deprecated Do not use Element directly. Pass VirtualNode instead
5+
* @param {VirtualNode|Element} element
6+
* @param {Object} context
7+
* @property {Bool} inLabelledByContext Whether or not the lookup is part of aria-describedby reference
8+
* @property {Bool} inControlContext Whether or not the lookup is part of a native label reference
9+
* @property {Element} startNode First node in accessible name computation
10+
* @property {Bool} debug Enable logging for formControlValue
11+
* @return {string} Concatenated text value for referenced elements
12+
*/
13+
function ariadescribedbyText(element, context = {}) {
14+
const { vNode } = axe.utils.nodeLookup(element);
15+
if (vNode?.props.nodeType !== 1) {
16+
return '';
17+
}
18+
19+
if (
20+
vNode.props.nodeType !== 1 ||
21+
context.inLabelledByContext ||
22+
context.inControlContext ||
23+
!vNode.attr('aria-describedby')
24+
) {
25+
return '';
26+
}
27+
28+
const refs = axe.commons.dom
29+
.idrefs(vNode, 'aria-describedby')
30+
.filter(elm => elm);
31+
return refs.reduce((accessibleName, elm) => {
32+
const accessibleNameAdd = axe.commons.text.accessibleText(elm, {
33+
// Prevent the infinite reference loop:
34+
inLabelledByContext: true,
35+
startNode: context.startNode || vNode,
36+
...context
37+
});
38+
39+
if (!accessibleName) {
40+
return accessibleNameAdd;
41+
}
42+
return `${accessibleName} ${accessibleNameAdd}`;
43+
}, '');
44+
}
45+
46+
export default ariadescribedbyText;

lib/commons/aria/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export { default as allowedAttr } from './allowed-attr';
77
export { default as arialabelText } from './arialabel-text';
88
export { default as arialabelledbyText } from './arialabelledby-text';
9+
export { default as ariadescribedbyText } from './ariadescribedby-text';
910
export { default as getAccessibleRefs } from './get-accessible-refs';
1011
export { default as getElementUnallowedRoles } from './get-element-unallowed-roles';
1112
export { default as getExplicitRole } from './get-explicit-role';

lib/commons/dom/get-overflow-hidden-ancestors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const getOverflowHiddenAncestors = memoize(
2828
ancestors.push(vNode);
2929
}
3030
} else {
31-
if (overflow.includes('hidden')) {
31+
if (overflow === 'hidden' || overflow.includes('clip')) {
3232
ancestors.push(vNode);
3333
}
3434
}

lib/core/base/rule.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '../utils';
1313
import { isVisibleToScreenReaders } from '../../commons/dom';
1414
import constants from '../constants';
15+
import cache from './cache';
1516

1617
export default function Rule(spec, parentAudit) {
1718
this._audit = parentAudit;
@@ -245,6 +246,7 @@ Rule.prototype.run = function run(context, options = {}, resolve, reject) {
245246
try {
246247
// Matches throws an error when it lacks support for document methods
247248
nodes = this.gatherAndMatchNodes(context, options);
249+
cache.set(this.id, nodes.length);
248250
} catch (error) {
249251
// Exit the rule execution if matches fails
250252
reject(new SupportError({ cause: error, ruleId: this.id }));

lib/core/utils/check-helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ function checkHelper(checkResult, options, resolve, reject) {
2525
data(data) {
2626
checkResult.data = data;
2727
},
28+
getCheckData() {
29+
return checkResult.data;
30+
},
2831
relatedNodes(nodes) {
2932
if (!window.Node) {
3033
return;

lib/core/utils/dq-element.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function getSource(element) {
2626
if (!source && typeof window.XMLSerializer === 'function') {
2727
source = new window.XMLSerializer().serializeToString(element);
2828
}
29-
return truncate(source || '');
29+
let htmlString = truncate(source || '');
30+
// Remove unwanted attributes
31+
const regex = /\s*data-percy-[^=]+="[^"]*"/g;
32+
htmlString = htmlString.replace(regex, '');
33+
return htmlString;
3034
}
3135

3236
/**

0 commit comments

Comments
 (0)