-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: reset title element to previous value on removal #14116
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||
import { render_effect } from '../../reactivity/effects.js'; | ||||||||||||||||||||||||||||||||||||||||||||
import { hydrating } from '../hydration.js'; | ||||||||||||||||||||||||||||||||||||||||||||
import { clear_text_content, get_first_child } from '../operations.js'; | ||||||||||||||||||||||||||||||||||||||||||||
import { queue_micro_task } from '../task.js'; | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -56,3 +57,17 @@ export function add_form_reset_listener() { | |||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||
* @param {string} text | ||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||
export function title(text) { | ||||||||||||||||||||||||||||||||||||||||||||
render_effect(() => { | ||||||||||||||||||||||||||||||||||||||||||||
const previous = document.title; | ||||||||||||||||||||||||||||||||||||||||||||
document.title = text; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
return () => { | ||||||||||||||||||||||||||||||||||||||||||||
document.title = previous; | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should handle another edge case - thoughts?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This handles the case where Setting They are both edge cases either way, so I'm ok with not adding this suggestion.
Comment on lines
+66
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.