-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(shared): unwrap refs in toDisplayString #7306
Merged
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
9 tasks
Size ReportBundles
Usages
|
# Conflicts: # packages/shared/src/toDisplayString.ts
CodSpeed Performance ReportMerging #7306 will not alter performanceComparing Summary
|
I was unaware of #5593 when I opened this. Here's a brief comparison:
|
haoqunjiang
added
🍰 p2-nice-to-have
Priority 2: this is not breaking anything but nice to have it addressed.
ready for review
This PR requires more reviews
labels
May 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🍰 p2-nice-to-have
Priority 2: this is not breaking anything but nice to have it addressed.
ready for review
This PR requires more reviews
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.
Closes #5578.
From the docs, https://vuejs.org/guide/essentials/reactivity-fundamentals.html#ref-unwrapping-in-templates:
This isn't quite true. The value of the ref will be passed through
JSON.stringify()
, even if the value is a primitive. For a number or a boolean this will just yield the expected string, but for a string value it leads to extra quotes and escaping:https://sfc.vuejs.org/#eNo9j8FOw0AMRH/F+BKQ6OYeFSRufIQvbXAgUXa9Wjv0EO2/420qbh579Ga840fO4XdjHPCsY5mzgbJt+Z3SHLMUgx0KT1BhKhKhc2tHidIoSQ3kuvBo8AY7JYBJZGjm5+6T11WA8CZl/SJ86l4oVUrn/ohwuAvjmNeLsSuAfX/AglOg3s3/BnzFo8wpXnJYVJLXvUfS46CEw1Gi7bxk04Q/ZlmHvtdpbE8uGqR89z6FsiWbIwfWeLoWuSkXBxM2hIdXrH+TUWJK
This PR aims to fix that problem by making
{{ object.foo }}
and{{ object.foo.value }}
equivalent for a refobject.foo
.Notes:
isRef
check is only performed when the value is an object, so it won't occur in the most common cases.toDisplayString
now calls itself recursively. While that has the potential to be problematic, in practice I don't think this introduces any new problems, asreplacer
is doing the same thing.