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

Incorrect Type Definition for popover Attribute in SvelteKit #2688

Open
karanravindra opened this issue Feb 8, 2025 · 1 comment
Open

Incorrect Type Definition for popover Attribute in SvelteKit #2688

karanravindra opened this issue Feb 8, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@karanravindra
Copy link

Describe the bug

Description:
The popover attribute does not have the correct type definition in SvelteKit's typings. According to the MDN documentation, the popover attribute is a boolean attribute when used without a value. When present without a value, it should default to "auto" instead of requiring an explicit value.

Example Code

This code should be valid, but TypeScript reports an error:

<button popovertarget="popover-div">Click me</button>
<div popover id="popover-div">
	...
</div>

Error Message

Type 'true' is not assignable to type '"" | "auto" | "manual" | null | undefined'.ts(2322)
(property) popover?: "" | "auto" | "manual" | null | undefined

Expected Behavior

  • The popover attribute should allow popover={true} as valid, reflecting its boolean HTML attribute behavior.
  • If popover is present without a value, it should default to "auto" rather than throwing a TypeScript error.

Suggested Fix

Update the type definition in SvelteKit’s typings to:

  • Accept true, allowing popover={true}.
  • Default to "auto" when popover is used without a value.

Reproduction

<button popovertarget="popover-div">Click me</button>
<div popover id="popover-div">
	...
</div>

Logs

System Info

System:
    OS: macOS 15.3
    CPU: (11) arm64 Apple M3 Pro
    Memory: 183.48 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.config/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.config/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.15.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.53
    Safari: 18.3

Severity

annoyance

@dummdidumm
Copy link
Member

popover is not a boolean attribute, as such not allowing popover={true} is correct. We need to adjust code in language tools to infer popover as popover={''}

@dummdidumm dummdidumm transferred this issue from sveltejs/svelte Feb 17, 2025
@dummdidumm dummdidumm added the bug Something isn't working label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants