fix(cascader): revert #2344 to fix not update when options change (#2843)

fix #2837, revert #2344
This commit is contained in:
Simona 2021-08-05 20:50:53 +08:00 committed by GitHub
parent a32ee8171c
commit 665ae6bd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 42 deletions

View File

@ -686,40 +686,4 @@ describe('CascaderPanel.vue', () => {
await wrapper.setProps({ options: NORMAL_OPTIONS })
expect(vm.getCheckedNodes(true).length).toBe(1)
})
test('should not re-init when props\'s reference change but value not change', async () => {
const mockLazyLoad = jest.fn()
const wrapper = _mount({
template: `
<cascader-panel
v-model="value"
:props="props"
/>
`,
data() {
return {
value: [],
props: {
lazy: true,
lazyLoad: mockLazyLoad,
},
}
},
})
await nextTick()
expect(mockLazyLoad).toBeCalled()
const sameMockLazyLoad = jest.fn()
wrapper.vm.props.lazyLoad = sameMockLazyLoad
await nextTick()
expect(sameMockLazyLoad).not.toBeCalled()
// should re-init when props's value change
const differentMockLazyLoad = jest.fn(lazyLoad)
wrapper.vm.props.lazyLoad = differentMockLazyLoad
await nextTick()
expect(differentMockLazyLoad).toBeCalled()
})
})

View File

@ -36,7 +36,6 @@ import {
coerceTruthyValueToArray,
deduplicate,
isEmpty,
isEqualWithFunction,
} from '@element-plus/utils/util'
import { CommonProps, useCascaderConfig } from './config'
import {
@ -298,11 +297,7 @@ export default defineComponent({
watch(
[ config, () => props.options ],
([newConfig, newOptions], [oldConfig, oldOptions]) => {
if (isEqualWithFunction(newConfig, oldConfig) && isEqual(newOptions, oldOptions)) return
initStore()
},
initStore,
{ deep: true, immediate: true },
)