Skip to content
Closed
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
56 changes: 32 additions & 24 deletions packages/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ function logFailureMessage(
): void {
// this exists on axe but we don't export it as part of the typescript
// namespace, so just let me use it as I need
const message: string = ((axeCore as unknown) as AxeWithAudit)._audit.data.failureSummaries[
key
].failureMessage(node[key].map(check => check.message || ''));
const message: string = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for this noise; these changes are from the formatter

axeCore as unknown as AxeWithAudit
)._audit.data.failureSummaries[key].failureMessage(
node[key].map(check => check.message || '')
);

console.error(message);
}
Expand Down Expand Up @@ -208,30 +210,31 @@ function checkAndReport(node: Node, timeout: number): Promise<void> {
}
}
axeCore.configure({ allowedOrigins: ['<unsafe_all_origins>'] });
axeCore.run(n, { reporter: 'v2' }, function (
error: Error,
results: axeCore.AxeResults
) {
if (error) {
return reject(error);
}

results.violations = results.violations.filter(result => {
result.nodes = result.nodes.filter(node => {
const key: string = node.target.toString() + result.id;
const retVal = !cache[key];
cache[key] = key;
return disableDeduplicate || retVal;
axeCore.run(
n,
{ reporter: 'v2' },
function (error: Error, results: axeCore.AxeResults) {
if (error) {
return reject(error);
}

results.violations = results.violations.filter(result => {
result.nodes = result.nodes.filter(node => {
const key: string = node.target.toString() + result.id;
const retVal = !cache[key];
cache[key] = key;
return disableDeduplicate || retVal;
});
return !!result.nodes.length;
});
return !!result.nodes.length;
});

if (results.violations.length) {
logger(results);
}
if (results.violations.length) {
logger(results);
}

resolve();
});
resolve();
}
);
},
{
timeout: timeout
Expand Down Expand Up @@ -286,6 +289,8 @@ function addComponent(component: any): void {
const reactInstanceDebugID = reactInstance._debugID;
const reactFiberInstance = component._reactInternalFiber || {};
const reactFiberInstanceDebugID = reactFiberInstance._debugID;
const reactInternals = component._reactInternals || {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rest of this code is the fix

const reactInternalsDebugID = reactInternals._debugID;

if (reactInstanceDebugID && !components[reactInstanceDebugID]) {
components[reactInstanceDebugID] = component;
Expand All @@ -296,6 +301,9 @@ function addComponent(component: any): void {
) {
components[reactFiberInstanceDebugID] = component;
componentAfterRender(component);
} else if (reactInternalsDebugID && !components[reactInternalsDebugID]) {
components[reactInternalsDebugID] = component;
componentAfterRender(component);
}
}

Expand Down