Skip to content
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): convert reactive string correctly in interpolation #11201

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update toDisplayString.ts
yyx990803 authored Jun 23, 2024
commit 1ba2266f720b060bc7ec6899f3cc17c00557cb6e
10 changes: 5 additions & 5 deletions packages/shared/src/toDisplayString.ts
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@ import {
export const toDisplayString = (val: unknown): string => {
return isString(val)
? val
: isRef(val) && isString(val.value)
? val.value
: isRef(val)
? toDisplayString(val.value)
: val == null
? ''
: isArray(val) ||
@@ -29,7 +29,6 @@ export const toDisplayString = (val: unknown): string => {
}

const replacer = (_key: string, val: any): any => {
// can't use isRef here since @vue/shared has no deps
if (isRef(val)) {
return replacer(_key, val.value)
} else if (isMap(val)) {
@@ -55,9 +54,10 @@ const replacer = (_key: string, val: any): any => {
return val
}

// can't use isRef from @vue/reactivity here since @vue/shared has no deps
const isRef = (val: any): val is { value: any } => val && val.__v_isRef

const stringifySymbol = (v: unknown, i: number | string = ''): any =>
// Symbol.description in es2019+ so we need to cast here to pass
// the lib: es2016 check
isSymbol(v) ? `Symbol(${(v as any).description ?? i})` : v

const isRef = (val: any): val is { value: any } => val && val.__v_isRef