From: daiwei Date: Tue, 18 Feb 2025 09:51:44 +0000 (+0800) Subject: chore: minor tweaks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fedison%2Ffix%2F%2312754;p=thirdparty%2Fvuejs%2Fcore.git chore: minor tweaks --- diff --git a/packages/runtime-core/src/helpers/useTemplateRef.ts b/packages/runtime-core/src/helpers/useTemplateRef.ts index aa31c29c22..0cf26e9840 100644 --- a/packages/runtime-core/src/helpers/useTemplateRef.ts +++ b/packages/runtime-core/src/helpers/useTemplateRef.ts @@ -10,6 +10,7 @@ export function useTemplateRef( ): Readonly> { const i = getCurrentInstance() const r = shallowRef(null) + const ret = __DEV__ ? readonly(r) : r if (i) { const refs = i.refs === EMPTY_OBJ ? (i.refs = {}) : i.refs const refsCache = @@ -17,7 +18,7 @@ export function useTemplateRef( if (refsCache.has(key)) { return refsCache.get(key)! } else { - refsCache.set(key, r) + refsCache.set(key, ret) Object.defineProperty(refs, key, { enumerable: true, get: () => r.value, @@ -30,7 +31,6 @@ export function useTemplateRef( `instance to be associated with.`, ) } - const ret = __DEV__ ? readonly(r) : r if (__DEV__) { knownTemplateRefs.add(ret) }