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

[Feature]: Reduce complexity in Primitive component #1491

Open
2 tasks
nandordudas opened this issue Dec 11, 2024 · 0 comments
Open
2 tasks

[Feature]: Reduce complexity in Primitive component #1491

nandordudas opened this issue Dec 11, 2024 · 0 comments

Comments

@nandordudas
Copy link

Describe the feature

Complexity can be changed but performance difference is negligible. Should I make a new PR for this or just say thank you for your work?

const SELF_CLOSING_TAGS = ['area', 'img', 'input']

const SELF_CLOSING_TAGS = new Set([
  'area',
  'img',
  'input',
  // add more...
] as const)

type SelfClosingTag = typeof SELF_CLOSING_TAGS extends Set<infer T>
  ? T
  : never

/**
 * Type guard to check if a tag is a void element
 * @param tag - The HTML tag to check
 * @returns True if the tag is a void element
 */
function isSelfClosingTag(tag: unknown): tag is SelfClosingTag {
  return typeof tag === 'string' && SELF_CLOSING_TAGS.has(tag as SelfClosingTag)
}

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant