Skip to content

Commit

Permalink
fix: Ref or computed inside non-wrappable variables (objects, arrays)…
Browse files Browse the repository at this point in the history
… should return a string without quotes(#5578)
  • Loading branch information
zhangshuai committed Mar 16, 2022
1 parent 5898629 commit 4d3d0d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/shared/__tests__/toDisplayString.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ describe('toDisplayString', () => {
np
})
).toBe(JSON.stringify({ n: 1, np: 2 }, null, 2))
// #5578
const nums = [ref('text')]
expect(toDisplayString(nums[0])).toBe('text')
})

test('objects with custom toString', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/shared/src/toDisplayString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
* For converting {{ interpolation }} values to displayed strings.
* @private
*/
export const toDisplayString = (val: unknown): string => {
export const toDisplayString = (val: any): string => {
//fix #5578
if (val && val.__v_isRef) {
return toDisplayString(val.value)
}
return isString(val)
? val
: val == null
Expand Down

0 comments on commit 4d3d0d6

Please sign in to comment.