Skip to content

Commit 5cf84c5

Browse files
committed
chore: minor tweaks
1 parent 09b25f1 commit 5cf84c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/runtime-core/src/helpers/useTemplateRef.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ export function useTemplateRef<T = unknown, Keys extends string = string>(
1010
): Readonly<ShallowRef<T | null>> {
1111
const i = getCurrentInstance()
1212
const r = shallowRef(null)
13+
const ret = __DEV__ ? readonly(r) : r
1314
if (i) {
1415
const refs = i.refs === EMPTY_OBJ ? (i.refs = {}) : i.refs
1516
const refsCache =
1617
i.refsCache || (i.refsCache = new Map<string, ShallowRef>())
1718
if (refsCache.has(key)) {
1819
return refsCache.get(key)!
1920
} else {
20-
refsCache.set(key, r)
21+
refsCache.set(key, ret)
2122
Object.defineProperty(refs, key, {
2223
enumerable: true,
2324
get: () => r.value,
@@ -30,7 +31,6 @@ export function useTemplateRef<T = unknown, Keys extends string = string>(
3031
`instance to be associated with.`,
3132
)
3233
}
33-
const ret = __DEV__ ? readonly(r) : r
3434
if (__DEV__) {
3535
knownTemplateRefs.add(ret)
3636
}

0 commit comments

Comments
 (0)