Skip to content

Commit de554b0

Browse files
authored
fix: Remove circular dependency (#800)
1 parent 42cd189 commit de554b0

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

.changeset/modern-carpets-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"dom-accessibility-api": patch
3+
---
4+
5+
Remover circular dependency, which fixes warnings thrown in certain environments.

sources/getRole.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html
22

3-
import { getLocalName } from "./util";
3+
/**
4+
* Safe Element.localName for all supported environments
5+
* @param element
6+
*/
7+
export function getLocalName(element: Element): string {
8+
return (
9+
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
10+
element.localName ??
11+
// eslint-disable-next-line no-restricted-properties -- required for the fallback
12+
element.tagName.toLowerCase()
13+
);
14+
}
415

516
const localNameToRoleMappings: Record<string, string | undefined> = {
617
article: "article",

sources/util.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import getRole from "./getRole";
2-
3-
/**
4-
* Safe Element.localName for all supported environments
5-
* @param element
6-
*/
7-
export function getLocalName(element: Element): string {
8-
return (
9-
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
10-
element.localName ??
11-
// eslint-disable-next-line no-restricted-properties -- required for the fallback
12-
element.tagName.toLowerCase()
13-
);
14-
}
1+
export { getLocalName } from "./getRole";
2+
import getRole, { getLocalName } from "./getRole";
153

164
export function isElement(node: Node | null): node is Element {
175
return node !== null && node.nodeType === node.ELEMENT_NODE;

0 commit comments

Comments
 (0)