Skip to content

Commit

Permalink
set
Browse files Browse the repository at this point in the history
  • Loading branch information
inker committed May 11, 2024
1 parent 985abf3 commit 7590b7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ui/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import htmlTags from 'html-tags';
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';

const htmlTagSet = new Set(htmlTags);

type TagName = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;

interface Props {
Expand All @@ -16,7 +18,7 @@ interface Props {
const Portal = ({ tagName, modalRoot, children }: Props) => {
const el = useMemo(() => {
const ns =
htmlTags.includes(tagName as (typeof htmlTags)[0]) && tagName !== 'svg'
htmlTagSet.has(tagName as (typeof htmlTags)[0]) && tagName !== 'svg'
? HTML_NAMESPACE
: SVG_NAMESPACE;
return document.createElementNS(ns, tagName) as HTMLElement;
Expand Down

0 comments on commit 7590b7c

Please sign in to comment.