fix(components): [select] solve memory leak (#19709)

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: 张东 <A80784@internet.com>
This commit is contained in:
锌小子
2025-02-16 10:24:46 +08:00
committed by GitHub
parent 7662aa05a2
commit 6dddd4ed54

View File

@@ -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)
}