Skip to content

Commit

Permalink
fix: remove circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-abc committed Feb 6, 2022
1 parent efd0f69 commit 035aeb2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-carpets-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"dom-accessibility-api": patch
---

Remover circular dependency, which fixes warnings thrown in certain environments.
13 changes: 12 additions & 1 deletion sources/getRole.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html

import { getLocalName } from "./util";
/**
* Safe Element.localName for all supported environments
* @param element
*/
export function getLocalName(element: Element): string {
return (
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
element.localName ??
// eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}

const localNameToRoleMappings: Record<string, string | undefined> = {
article: "article",
Expand Down
16 changes: 2 additions & 14 deletions sources/util.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import getRole from "./getRole";

/**
* Safe Element.localName for all supported environments
* @param element
*/
export function getLocalName(element: Element): string {
return (
// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
element.localName ??
// eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}
export { getLocalName } from "./getRole";
import getRole, { getLocalName } from "./getRole";

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

0 comments on commit 035aeb2

Please sign in to comment.