MCPcopy
hub / github.com/vuejs/core / formatProp

Function formatProp

packages/runtime-core/src/warning.ts:148–167  ·  view source on GitHub ↗
(key: string, value: unknown, raw?: boolean)

Source from the content-addressed store, hash-verified

146function formatProp(key: string, value: unknown): any[]
147function formatProp(key: string, value: unknown, raw: true): any
148function formatProp(key: string, value: unknown, raw?: boolean): any {
149 if (isString(value)) {
150 value = JSON.stringify(value)
151 return raw ? value : [`${key}=${value}`]
152 } else if (
153 typeof value === 'number' ||
154 typeof value === 'boolean' ||
155 value == null
156 ) {
157 return raw ? value : [`${key}=${value}`]
158 } else if (isRef(value)) {
159 value = formatProp(key, toRaw(value.value), true)
160 return raw ? value : [`${key}=Ref<`, value, `>`]
161 } else if (isFunction(value)) {
162 return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]
163 } else {
164 value = toRaw(value)
165 return raw ? value : [`${key}=`, value]
166 }
167}
168
169/**
170 * @internal

Callers 1

formatPropsFunction · 0.85

Calls 4

isStringFunction · 0.90
isRefFunction · 0.90
toRawFunction · 0.90
isFunctionFunction · 0.90

Tested by

no test coverage detected