Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fix: reset title element to previous value on removal #14116
base: main
Are you sure you want to change the base?
fix: reset title element to previous value on removal #14116
Changes from all commits
c9f5147
3265021
963d393
2072638
3904b8f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should handle another edge case - thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which case would this prevent? It actually seems to me like this might make bugs more likely, since if a component had a
<title>
and also contained a component that setdocument.title
in a user effect, it wouldn't revert either when the parent was removedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handles the case where
A
sets the title, thenB
is mounted and sets the title, thenA
updates the title (in other words it contains something like<title>{foo}</title>
), thenB
is removed - in that case we wouldn't want the title to be reverted back to whatA
had initially, we want to preserve the title.Setting
document.title
in a user effect manually feels a bit like "working against the framework", you should just do that declaratively.They are both edge cases either way, so I'm ok with not adding this suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also do this, would handle the case described in https://github.com/sveltejs/svelte/pull/14116/files#r1876874053
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how the code is generated, we should switch it up anyway - right now if your title would contain dynamic content, you would set it two times on an update - once to revert to the previous value, then right away again for the updated value. Wasteful.