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

release-3.4.0 #114

Merged
merged 12 commits into from
Dec 24, 2024
8 changes: 8 additions & 0 deletions lib/checks/color/link-in-text-block-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ function getColorContrast(node, parentBlock) {
nodeColor = getForegroundColor(node);
parentColor = getForegroundColor(parentBlock);

if (!nodeColor) {
nodeColor = new axe.commons.color.Color(0, 0, 0, 0);
}

if (!parentColor) {
parentColor = new axe.commons.color.Color(0, 0, 0, 0);
}

if (!nodeColor || !parentColor) {
return undefined;
}
Expand Down
46 changes: 46 additions & 0 deletions lib/commons/aria/ariadescribedby-text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Get the accessible name based on aria-describedby
*
* @deprecated Do not use Element directly. Pass VirtualNode instead
* @param {VirtualNode|Element} element
* @param {Object} context
* @property {Bool} inLabelledByContext Whether or not the lookup is part of aria-describedby reference
* @property {Bool} inControlContext Whether or not the lookup is part of a native label reference
* @property {Element} startNode First node in accessible name computation
* @property {Bool} debug Enable logging for formControlValue
* @return {string} Concatenated text value for referenced elements
*/
function ariadescribedbyText(element, context = {}) {
const { vNode } = axe.utils.nodeLookup(element);
if (vNode?.props.nodeType !== 1) {
return '';
}

if (
vNode.props.nodeType !== 1 ||
context.inLabelledByContext ||
context.inControlContext ||
!vNode.attr('aria-describedby')
) {
return '';
}

const refs = axe.commons.dom
.idrefs(vNode, 'aria-describedby')
.filter(elm => elm);
return refs.reduce((accessibleName, elm) => {
const accessibleNameAdd = axe.commons.text.accessibleText(elm, {
// Prevent the infinite reference loop:
inLabelledByContext: true,
startNode: context.startNode || vNode,
...context
});

if (!accessibleName) {
return accessibleNameAdd;
}
return `${accessibleName} ${accessibleNameAdd}`;
}, '');
}

export default ariadescribedbyText;
1 change: 1 addition & 0 deletions lib/commons/aria/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export { default as allowedAttr } from './allowed-attr';
export { default as arialabelText } from './arialabel-text';
export { default as arialabelledbyText } from './arialabelledby-text';
export { default as ariadescribedbyText } from './ariadescribedby-text';
export { default as getAccessibleRefs } from './get-accessible-refs';
export { default as getElementUnallowedRoles } from './get-element-unallowed-roles';
export { default as getExplicitRole } from './get-explicit-role';
Expand Down
2 changes: 1 addition & 1 deletion lib/commons/dom/get-overflow-hidden-ancestors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getOverflowHiddenAncestors = memoize(
ancestors.push(vNode);
}
} else {
if (overflow.includes('hidden')) {
if (overflow === 'hidden' || overflow.includes('clip')) {
ancestors.push(vNode);
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/core/base/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../utils';
import { isVisibleToScreenReaders } from '../../commons/dom';
import constants from '../constants';
import cache from './cache';

export default function Rule(spec, parentAudit) {
this._audit = parentAudit;
Expand Down Expand Up @@ -245,6 +246,7 @@ Rule.prototype.run = function run(context, options = {}, resolve, reject) {
try {
// Matches throws an error when it lacks support for document methods
nodes = this.gatherAndMatchNodes(context, options);
cache.set(this.id, nodes.length);
} catch (error) {
// Exit the rule execution if matches fails
reject(new SupportError({ cause: error, ruleId: this.id }));
Expand Down
3 changes: 3 additions & 0 deletions lib/core/utils/check-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function checkHelper(checkResult, options, resolve, reject) {
data(data) {
checkResult.data = data;
},
getCheckData() {
return checkResult.data;
},
relatedNodes(nodes) {
if (!window.Node) {
return;
Expand Down
6 changes: 5 additions & 1 deletion lib/core/utils/dq-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ function getSource(element) {
if (!source && typeof window.XMLSerializer === 'function') {
source = new window.XMLSerializer().serializeToString(element);
}
return truncate(source || '');
let htmlString = truncate(source || '');
// Remove unwanted attributes
const regex = /\s*data-percy-[^=]+="[^"]*"/g;
htmlString = htmlString.replace(regex, '');
return htmlString;
}

/**
Expand Down
Loading