perf(components): [loading] unmount instance when loading end (#7110)

Co-authored-by: 周陈旻琨 <zhouchenminkun@stary.com>
This commit is contained in:
DoubleBird
2022-04-12 02:02:55 +08:00
committed by GitHub
parent 9c7c61eac5
commit a1a24edef2
3 changed files with 5 additions and 3 deletions

View File

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

View File

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

View File

@@ -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({