-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(useTitle): prevent observe
and titleTemplate
been specified at the same time
#2049
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe instead we should throw an error to now allow using |
huynl-96
force-pushed
the
fix/useTitle-types
branch
from
August 26, 2022 02:42
f582db1
to
53cf00f
Compare
huynl-96
force-pushed
the
fix/useTitle-types
branch
from
August 26, 2022 03:12
53cf00f
to
d78bb34
Compare
@antfu I've updated the implementation to throw error. Please kindly check it when you're available. |
antfu
changed the title
fix(useTitle): prevent title from update infinitely
fix(useTitle): prevent Oct 16, 2022
observe
and titleTemplate
been specified at the same time
In VueUse we don't throw errors as the message would increase the bundle size and impossible to do i18n. Changed to do it on type level, and force observe disabled when occurred at the same time. |
antfu
previously approved these changes
Oct 16, 2022
antfu
reviewed
Oct 16, 2022
antfu
approved these changes
Oct 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When setting
observe
totrue
, it only works well with defaulttitleTemplate
(which returns the exact input title e.g.'%s'
,(title) => title
).If changing
titleTemplate
into any other string template. e.g.When we try to input the first character,
title
ref changes which then leads to the change ofdocument.title
. But sincedocument.title
andtitle
are not the same due totitleTemplate
, it again reassigns the new value fromdocument.title
totitle
ref.The above process keeps repeating and freezes the entire page.
Screen.Recording.2022-08-05.at.16.51.38.mov
Additional context
observe
withtitleTemplate
useTitle
titleTemplate
stringWhat is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).