From 6dddd4ed54f32eb82f658cfce1cef76482ac0a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=8C=E5=B0=8F=E5=AD=90?= <2252647301@qq.com> Date: Sun, 16 Feb 2025 10:24:46 +0800 Subject: [PATCH] fix(components): [select] solve memory leak (#19709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(components): solve memory leak Watching the value of an attribute of an option can lead to a memory leak closed #19680 Co-authored-by: 张东 --- packages/components/select/src/useOption.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/select/src/useOption.ts b/packages/components/select/src/useOption.ts index 3c37bfe31a..1c7180ed1c 100644 --- a/packages/components/select/src/useOption.ts +++ b/packages/components/select/src/useOption.ts @@ -1,6 +1,6 @@ // @ts-nocheck import { computed, getCurrentInstance, inject, toRaw, watch } from 'vue' -import { get } from 'lodash-unified' +import { get, isEqual } from 'lodash-unified' import { ensureArray, escapeStringRegexp, isObject } from '@element-plus/utils' import { selectGroupKey, selectKey } from './token' @@ -77,8 +77,8 @@ export function useOption(props, states) { () => props.value, (val, oldVal) => { const { remote, valueKey } = select.props - - if (val !== oldVal) { + const shouldUpdate = remote ? val !== oldVal : !isEqual(val, oldVal) + if (shouldUpdate) { select.onOptionDestroy(oldVal, instance.proxy) select.onOptionCreate(instance.proxy) }