-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Allow attributes on the <title>
element
#5198
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
Comments
I've never seen such a pattern before but, as you point out, it seems to be valid HTML. That change was introduced in this PR but there's no apparent reason as to why. I can open a PR removing that but I'm afraid I'm missing something here. |
It makes sense to remove the validation since the spec allows global attributes. https://html.spec.whatwg.org/#the-title-element |
I talked about this on Discord and it seems like the maintainers are not willing to remove the validation. The argument being that the article posted by op is an experiment more than good practice. I too consider the validation to be irrelevant given that it should be allowed, according to the spec. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The spec states the title element supports global attributes. https://html.spec.whatwg.org/#the-title-element Reverts the title attribute validation introduced in sveltejs#1721. Fixes sveltejs#5198.
The spec states the title element supports global attributes. https://html.spec.whatwg.org/#the-title-element Reverts the title attribute validation introduced in sveltejs#1721. Fixes sveltejs#5198.
Hi all, I'm interested in Svelte, so I figured I'd try my hand at some easy-ish issues to get a feel for it. I threw up a PR to fix this issue, #15983. I'm happy to modify or close the PR if this behavior is no longer desired. |
Is your feature request related to a problem? Please describe.
Looks like the
<title>
element is [barred from having any attributes] (https://github.com/sveltejs/svelte/blob/master/src/compiler/compile/nodes/Title.ts). According to MDN, it can host any global attribute. It was a bit of a surprise that it had special treatment.This prevents adding to it an
aria-live
attribute that would allow its announcement by assistive technology (provided it's unhidden from the accessibility tree, see experiment there: https://romaricpascal.is/posts/title-element-aria-live/).Describe the solution you'd like
At the moment, it looks like the attribute can be set through an
onMount()
call:but it'd be great to just be able to do:
This would also make updating whether the title should be announced lighter, especially if the value comes from a store:
Describe alternatives you've considered
Using
onMount
provides a workable workaround. There's just a bit of logistics if attributes need to come from a store or multiple attributes need setting (but in my use-case, that would only bearia-live
).How important is this feature to you?
It's not a dealbreaker that it's not there. It just feels less idiomatic to have all that boilerplate around. It was also confusing to have that specific tag not work as a regular tag (maybe it's a matter of documentation, though).
The text was updated successfully, but these errors were encountered: