Skip to content

Commit 80e47c2

Browse files
张东张东
张东
authored and
张东
committed
fix(components): solve memory leak
Watching the value of an attribute of an option can lead to a memory leak closed element-plus#19680
1 parent 049ed2a commit 80e47c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/components/select/src/useOption.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22
import { computed, getCurrentInstance, inject, toRaw, watch } from 'vue'
3-
import { get } from 'lodash-unified'
3+
import { get, isEqual } from 'lodash-unified'
44
import { ensureArray, escapeStringRegexp, isObject } from '@element-plus/utils'
55
import { selectGroupKey, selectKey } from './token'
66

@@ -77,8 +77,8 @@ export function useOption(props, states) {
7777
() => props.value,
7878
(val, oldVal) => {
7979
const { remote, valueKey } = select.props
80-
81-
if (val !== oldVal) {
80+
const shouldUpdate = remote ? val !== oldVal : !isEqual(val, oldVal)
81+
if (shouldUpdate) {
8282
select.onOptionDestroy(oldVal, instance.proxy)
8383
select.onOptionCreate(instance.proxy)
8484
}

0 commit comments

Comments
 (0)