Skip to content

Commit

Permalink
Merge pull request #4 from iansan5653/fix-error-soft-nav
Browse files Browse the repository at this point in the history
Fix error thrown when element already registered (on soft navigation)
  • Loading branch information
iansan5653 authored May 22, 2024
2 parents ad4bfbb + 96877e5 commit 5d5fb7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/input-style-clone-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,11 @@ const propertiesToCopy = [
"MozTabSize" as "tabSize", // prefixed version for Firefox <= 52
] as const satisfies ReadonlyArray<keyof CSSStyleDeclaration>;

customElements.define("input-style-clone", InputStyleCloneElement);
// Inspired by https://github.com/github/catalyst/blob/dc284dcf4f82329a9cac5c867462a8fa529b6c40/src/register.ts

try {
customElements.define("input-style-clone", InputStyleCloneElement);
} catch (e: unknown) {
// Throws DOMException with NotSupportedError if already defined
if (!(e instanceof DOMException && e.name === "NotSupportedError")) throw e;
}

0 comments on commit 5d5fb7a

Please sign in to comment.