Skip to content

Commit

Permalink
feat(types): add ComputedAccessibleNode type
Browse files Browse the repository at this point in the history
  • Loading branch information
masuP9 committed Nov 22, 2020
1 parent 41f5515 commit bcd4322
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/acot-preset-wcag/src/rules/interactive-has-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRule } from '@acot/core';
import { getEventListeners } from '@acot/utils';
import type { ComputedAccessibleNode } from '@acot/types';

type Options = {};

Expand Down Expand Up @@ -33,7 +34,9 @@ export default createRule<Options>({
await Promise.all(
elements.map(async (node) => {
const name = await node.evaluate(async (el) => {
const ax = await (window as any).getComputedAccessibleNode(el);
const ax = await ((window as any).getComputedAccessibleNode(
el,
) as ComputedAccessibleNode);
return (ax?.name ?? '').trim();
});

Expand Down
37 changes: 37 additions & 0 deletions packages/types/src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export type ComputedAccessibleNode = {
atomic?: boolean;
busy?: boolean;
disabled?: boolean;
expanded?: boolean;
modal?: boolean;
multiline?: boolean;
multiselectable?: boolean;
readOnly?: boolean;
required?: boolean;
selected?: boolean;
colCount?: number;
colIndex?: number;
colSpan?: number;
level?: number;
posInSet?: number;
rowCount?: number;
rowIndex?: number;
rowSpan?: number;
setSize?: number;
valueMax?: number;
valueMin?: number;
valueNow?: number;
autocomplete?: string;
checked?: string;
keyShortcuts?: string;
name?: string;
placeholder?: string;
role?: string;
roleDescription?: string;
valueText?: string;
parent?: ComputedAccessibleNode;
firstChild?: ComputedAccessibleNode;
lastChild?: ComputedAccessibleNode;
previousSibling?: ComputedAccessibleNode;
nextSibling?: ComputedAccessibleNode;
};
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './browser';
export * from './config';
export * from './core';
export * from './event';
Expand Down

0 comments on commit bcd4322

Please sign in to comment.