sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.4k stars 4.11k forks source link

Custom Elements can have a tag name ending with a hyphen #13244

Closed Ocean-OS closed 3 days ago

Ocean-OS commented 5 days ago

Describe the bug

When using the customElement tag in svelte:options, it only allows names that have a hyphen (that is not at the beginning or end). However, Custom Elements are allowed to have a name ending with a hyphen.

Example

component is an invalid name in both Custom Elements and Svelte. component-name is a valid name in both Custom Elements and Svelte. component- is a valid name in Custom Elements, but an invalid name in Svelte.

Reproduction

REPL link

Logs

No response

System Info

System info is not necessary for this issue. 
The error occurs in all versions of Svelte.

Severity

annoyance

7nik commented 4 days ago

From WHATWG specs


If I see a tag with a hyphen at the end, I think it is a typo; it is a really bad name. The name can include emojis and other things — not a good style, but not as bad as ending with a hyphen. And there is a list of forbidden names - Svelte doesn't seem to forbid them even in types, though you'll immediately get a runtime error.