From 96c1af8c0dafcf23ea21bad4b396c0caddff8aed Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 1 Nov 2023 21:26:51 +0100 Subject: [PATCH 1/5] fix(d.ts): RawNodesResult issues --- axe.d.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index 403e504873..732e917c80 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -1,6 +1,5 @@ // Type definitions for axe-core // Project: https://github.com/dequelabs/axe-core -// Definitions by: Marcy Sutton declare namespace axe { type ImpactValue = 'minor' | 'moderate' | 'serious' | 'critical' | null; @@ -351,16 +350,21 @@ declare namespace axe { frameContext: FrameContextObject; } + interface RawCheckResult extends Omit { + relatedNodes?: SerialDqElement[]; + } + interface RawNodeResult { - any: CheckResult[]; - all: CheckResult[]; - none: CheckResult[]; + node: SerialDqElement; + any: RawCheckResult[]; + all: RawCheckResult[]; + none: RawCheckResult[]; impact: ImpactValue | null; result: T; } interface RawResult extends Omit { - inapplicable: []; + inapplicable: Array; passes: RawNodeResult<'passed'>[]; incomplete: RawNodeResult<'incomplete'>[]; violations: RawNodeResult<'failed'>[]; @@ -383,6 +387,7 @@ declare namespace axe { attr(attr: string): string | null; hasAttr(attr: string): boolean; props: { [key: string]: unknown }; + boundingClientRect: DOMRect; } interface Utils { From ab3900865e7e6c516b5726855a94ecec52124aad Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 1 Nov 2023 21:39:25 +0100 Subject: [PATCH 2/5] Type tests --- typings/axe-core/axe-core-tests.ts | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/typings/axe-core/axe-core-tests.ts b/typings/axe-core/axe-core-tests.ts index bff4ec46da..99ef031b3b 100644 --- a/typings/axe-core/axe-core-tests.ts +++ b/typings/axe-core/axe-core-tests.ts @@ -344,6 +344,41 @@ axe.configure({ } }); +const results: axe.RawResult[] = [ + { + id: 'the-best-rule', + result: 'passed', + pageLevel: false, + impact: null, + tags: ['best-practice'], + description: 'Be cool', + help: 'No, cooler', + helpUrl: + 'https://dequeuniversity.com/rules/axe/4.8/the-best-rule?application=axeAPI', + inapplicable: [], + passes: [ + { + any: [ + { + id: 'the-best-check', + data: null, + impact: 'serious', + message: 'Element has sufficient color contrast of 21', + relatedNodes: [new axe.utils.DqElement(document.body)] + } + ], + all: [], + none: [], + impact: null, + result: 'passed', + node: new axe.utils.DqElement(document.body) + } + ], + incomplete: [], + violations: [] + } +]; + // Reporters let fooReporter = ( results: axe.RawResult[], From 0b6c1237b5bc12f2f6f2593d27824c019a140805 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 1 Nov 2023 22:03:39 +0100 Subject: [PATCH 3/5] More --- axe.d.ts | 14 +++++++++++--- typings/axe-core/axe-core-tests.ts | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index 732e917c80..b45190010a 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -332,6 +332,14 @@ declare namespace axe { xpath: string[]; ancestry: UnlabelledFrameSelector; } + interface DqElement extends axe.SerialDqElement { + element: Element; + toJSON(): axe.SerialDqElement; + mergeSpecs( + childSpec: axe.SerialDqElement, + parentSpec: axe.SerialDqElement + ): axe.SerialDqElement; + } interface PartialRuleResult { id: string; result: 'inapplicable'; @@ -351,11 +359,11 @@ declare namespace axe { } interface RawCheckResult extends Omit { - relatedNodes?: SerialDqElement[]; + relatedNodes?: Array; } interface RawNodeResult { - node: SerialDqElement; + node: SerialDqElement | DqElement; any: RawCheckResult[]; all: RawCheckResult[]; none: RawCheckResult[]; @@ -401,7 +409,7 @@ declare namespace axe { DqElement: new ( elm: Element, options?: { absolutePaths?: boolean } - ) => SerialDqElement; + ) => DqElement; uuid: ( options?: { random?: Uint8Array | Array }, buf?: Uint8Array | Array, diff --git a/typings/axe-core/axe-core-tests.ts b/typings/axe-core/axe-core-tests.ts index 99ef031b3b..094b30d64c 100644 --- a/typings/axe-core/axe-core-tests.ts +++ b/typings/axe-core/axe-core-tests.ts @@ -364,7 +364,10 @@ const results: axe.RawResult[] = [ data: null, impact: 'serious', message: 'Element has sufficient color contrast of 21', - relatedNodes: [new axe.utils.DqElement(document.body)] + relatedNodes: [ + new axe.utils.DqElement(document.body), + new axe.utils.DqElement(document.body).toJSON() + ] } ], all: [], From c6bc9ce2c80387d503b3aa19d55725ebaf4ff0a4 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 1 Nov 2023 22:13:51 +0100 Subject: [PATCH 4/5] empty From c8194c4a80d3c81d62f9253d26b54aed99da906d Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 1 Nov 2023 23:30:06 +0100 Subject: [PATCH 5/5] Fixed feedback --- axe.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index b45190010a..7f33941d94 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -332,13 +332,13 @@ declare namespace axe { xpath: string[]; ancestry: UnlabelledFrameSelector; } - interface DqElement extends axe.SerialDqElement { + interface DqElement extends SerialDqElement { element: Element; - toJSON(): axe.SerialDqElement; + toJSON(): SerialDqElement; mergeSpecs( - childSpec: axe.SerialDqElement, - parentSpec: axe.SerialDqElement - ): axe.SerialDqElement; + childSpec: SerialDqElement, + parentSpec: SerialDqElement + ): SerialDqElement; } interface PartialRuleResult { id: string;