mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
parent
a32ee8171c
commit
665ae6bd20
@ -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()
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -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 },
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user