Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove circular dependency #800

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
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
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