Custom Elements can have a tag name ending with a hyphen
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
Logs
No response
System Info
System info is not necessary for this issue.
The error occurs in all versions of Svelte.
Severity
annoyance
From WHATWG specs
-
name must match the
PotentialCustomElementNameproduction:-
PotentialCustomElementName::=[a-z] (PCENChar)* '-' (PCENChar)* -
PCENChar::="-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
-
-
name must not be any of the following:
- annotation-xml
- color-profile
- font-face
- font-face-src
- font-face-uri
- font-face-format
- font-face-name
- missing-glyph
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.