mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
perf(components): [loading] unmount instance when loading end (#7110)
Co-authored-by: 周陈旻琨 <zhouchenminkun@stary.com>
This commit is contained in:
@@ -261,6 +261,7 @@ describe('Loading', () => {
|
||||
await nextTick()
|
||||
|
||||
let masks = document.querySelectorAll('.el-loading-mask')
|
||||
expect(loadingInstance).toEqual(loadingInstance2)
|
||||
expect(masks.length).toEqual(1)
|
||||
loadingInstance2.close()
|
||||
jest.runAllTimers()
|
||||
|
||||
@@ -44,6 +44,7 @@ export function createLoadingComponent(options: LoadingOptionsResolved) {
|
||||
removeClass(target, 'el-loading-parent--hidden')
|
||||
}
|
||||
remvoeElLoadingChild()
|
||||
loadingInstance.unmount()
|
||||
}
|
||||
function remvoeElLoadingChild(): void {
|
||||
vm.$el?.parentNode?.removeChild(vm.$el)
|
||||
@@ -140,7 +141,8 @@ export function createLoadingComponent(options: LoadingOptionsResolved) {
|
||||
},
|
||||
}
|
||||
|
||||
const vm = createApp(elLoadingComponent).mount(document.createElement('div'))
|
||||
const loadingInstance = createApp(elLoadingComponent)
|
||||
const vm = loadingInstance.mount(document.createElement('div'))
|
||||
|
||||
return {
|
||||
...toRefs(data),
|
||||
|
||||
@@ -19,8 +19,7 @@ export const Loading = function (
|
||||
const resolved = resolveOptions(options)
|
||||
|
||||
if (resolved.fullscreen && fullscreenInstance) {
|
||||
fullscreenInstance.remvoeElLoadingChild()
|
||||
fullscreenInstance.close()
|
||||
return fullscreenInstance
|
||||
}
|
||||
|
||||
const instance = createLoadingComponent({
|
||||
|
||||
Reference in New Issue
Block a user