-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: allow attributes on the title element #15983
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
base: main
Are you sure you want to change the base?
Conversation
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.
🦋 Changeset detectedLatest commit: 8740110 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Thank you. The When you create a |
Ah, I see. I'll take a crack at rendering the attributes. Should I limit attributes to a subset? |
I don't think there's any reason to limit it, it's extra work to prevent something that someone might find useful in ways we don't anticipate. I think the most interesting challenge here will be hydration, since in the (admittedly rare!) case of duplicate elements they need to be rendered in reverse order, so that 'later' |
SSR is pretty straight-forward. The client side is more difficult since the TitleElement doesn't have a node_id.
I added SSR title tag attributes by cribbing code from RegularElement in the latest commit. Client-side rendering is trickier, and I could use some pointers. The TitleElement doesn't have a reference to the HTML element because we didn't need one before. To call build_set_attributes, I need a node_id, from The code for adding attributes is inlined in the client RegularElement. I extracted the smallest chunk of code into TitleElement to make it work.
|
The spec states the title element supports global attributes. https://html.spec.whatwg.org/#the-title-element
Reverts the title attribute validation introduced in #1721.
Fixes #5198.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
The test plan is to re-use packages/svelte/tests/validator/samples/title-no-attributes. By removing errors.json, we test that svelte compiles the title element with attributes.
pnpm test
and lint the project withpnpm lint
The tests pass, but
pnpm lint
failed with: