Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let nodeElem;
let classNamesToAdd;
for (let i = 0, l = violations.length; i < l; i++) {
violation = violations[i];
nodes = violation.nodes;
if (isEmpty(nodes) || nodes.length === 0) {
console.error(formatViolation(violation), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
for (let j = 0, k = nodes.length; j < k; j++) {
nodeData = nodes[j];
console.error(formatViolation(violation, nodeData.html), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
if (nodeData) {
nodeElem = document.querySelector(nodeData.target.join(','));
classNamesToAdd = isBackgroundReplacedElement(nodeElem) ? [VIOLATION_CLASS_MAP.REPLACED_ELEMENT] : violationClasses;
nodeElem.classList.remove(...VIOLATION_CLASS_NAMES);
if (visualNoiseLevel > 0) {
nodeElem.classList.add(...classNamesToAdd);
}
}
}
}
if (this.axeCallback) {
function a11yAuditCallback(results) {
let violations = results.violations;
if (violations.length) {
let allViolations = [];
for (let i = 0, l = violations.length; i < l; i++) {
let violation = violations[i];
let violationNodes = violation.nodes.map(node => node.html);
let violationMessage = formatViolation(violation, violationNodes);
allViolations.push(violationMessage);
console.error(violationMessage, violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
let allViolationMessages = allViolations.join('\n');
assert(`The page should have no accessibility violations. Violations:\n${allViolationMessages}`);
}
}
const violations = results.violations;
const violationClasses = this.get('violationClasses') || [];
const visualNoiseLevel = this.get('visualNoiseLevel');
let violation;
let nodes;
let nodeData;
let nodeElem;
let classNamesToAdd;
for (let i = 0, l = violations.length; i < l; i++) {
violation = violations[i];
nodes = violation.nodes;
if (isEmpty(nodes) || nodes.length === 0) {
console.error(formatViolation(violation), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
for (let j = 0, k = nodes.length; j < k; j++) {
nodeData = nodes[j];
console.error(formatViolation(violation, nodeData.html), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
if (nodeData) {
nodeElem = document.querySelector(nodeData.target.join(','));
classNamesToAdd = isBackgroundReplacedElement(nodeElem) ? [VIOLATION_CLASS_MAP.REPLACED_ELEMENT] : violationClasses;
nodeElem.classList.remove(...VIOLATION_CLASS_NAMES);
if (visualNoiseLevel > 0) {
const violationClasses = this.get('violationClasses') || [];
const visualNoiseLevel = this.get('visualNoiseLevel');
let violation;
let nodes;
let nodeData;
let nodeElem;
let classNamesToAdd;
for (let i = 0, l = violations.length; i < l; i++) {
violation = violations[i];
nodes = violation.nodes;
if (isEmpty(nodes) || nodes.length === 0) {
console.error(formatViolation(violation), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
for (let j = 0, k = nodes.length; j < k; j++) {
nodeData = nodes[j];
console.error(formatViolation(violation, nodeData.html), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
if (nodeData) {
nodeElem = document.querySelector(nodeData.target.join(','));
classNamesToAdd = isBackgroundReplacedElement(nodeElem) ? [VIOLATION_CLASS_MAP.REPLACED_ELEMENT] : violationClasses;
nodeElem.classList.remove(...VIOLATION_CLASS_NAMES);
if (visualNoiseLevel > 0) {
nodeElem.classList.add(...classNamesToAdd);
function a11yAuditCallback(results) {
let violations = results.violations;
if (violations.length) {
let allViolations = [];
for (let i = 0, l = violations.length; i < l; i++) {
let violation = violations[i];
let violationNodes = violation.nodes.map(node => node.html);
let violationMessage = formatViolation(violation, violationNodes);
allViolations.push(violationMessage);
console.error(violationMessage, violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
let allViolationMessages = allViolations.join('\n');
assert(`The page should have no accessibility violations. Violations:\n${allViolationMessages}`);
}
}
nodes = violation.nodes;
if (isEmpty(nodes) || nodes.length === 0) {
console.error(formatViolation(violation), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
}
for (let j = 0, k = nodes.length; j < k; j++) {
nodeData = nodes[j];
console.error(formatViolation(violation, nodeData.html), violation); // eslint-disable-line no-console
violationsHelper.push(violation);
if (nodeData) {
nodeElem = document.querySelector(nodeData.target.join(','));
classNamesToAdd = isBackgroundReplacedElement(nodeElem) ? [VIOLATION_CLASS_MAP.REPLACED_ELEMENT] : violationClasses;
nodeElem.classList.remove(...VIOLATION_CLASS_NAMES);
if (visualNoiseLevel > 0) {
nodeElem.classList.add(...classNamesToAdd);
}
}
}
}
if (this.axeCallback) {
assert('axeCallback should be a function.', typeof this.axeCallback === 'function');
this.axeCallback(results);
}
scheduleOnce('afterRender', violationsHelper, violationsHelper.logTip);
audit() {
if (this.get('tagName') !== '') {
concurrentAxe.run(this.element, this.axeOptions, (error, results) => {
if (this.get('isDestroyed')) {
return;
}
if (error) {
throw error;
}
const violations = results.violations;
const violationClasses = this.get('violationClasses') || [];
const visualNoiseLevel = this.get('visualNoiseLevel');
let violation;
let nodes;
let nodeData;
let nodeElem;
nodeElem.classList.remove(...VIOLATION_CLASS_NAMES);
if (visualNoiseLevel > 0) {
nodeElem.classList.add(...classNamesToAdd);
}
}
}
}
if (this.axeCallback) {
assert('axeCallback should be a function.', typeof this.axeCallback === 'function');
this.axeCallback(results);
}
scheduleOnce('afterRender', violationsHelper, violationsHelper.logTip);
});
}