fix(loading): fix loading error show when parent's display is not block (#1250)

* fix(loading): fix loading error show when parent's display is not block

* test(loading): add loading test case
This commit is contained in:
Ryan2128 2021-01-10 20:31:31 -06:00 committed by GitHub
parent e112b9c83b
commit 513908a829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import { mount } from '@vue/test-utils'
import Loading from '../src/index'
import ElInput from '../../input'
import vLoading from '../src/directive'
import { nextTick } from 'vue'
import { sleep } from '@element-plus/test-utils'
@ -253,4 +254,22 @@ describe('Loading', () => {
expect(customClass).toBeTruthy()
})
test('parent\'s display is not block', async () => {
const wrapper = mount({
directives: {
loading: vLoading,
},
components: {
ElInput,
},
template: `<el-input v-loading="true">
<template #append>
<i class="el-icon-question"></i>
</template>
</el-input>`,
})
const maskDisplay = getComputedStyle(wrapper.find('.el-loading-mask').element).display
expect(maskDisplay).toBe('block')
})
})

View File

@ -84,7 +84,7 @@ export function createLoadingComponent({ options , globalLoadingOption }: ILoadi
default: () => h('div', {
style: {
backgroundColor: this.background || '',
display: this.visible ? 'inherit' : 'none',
display: this.visible ? null : 'none',
},
class: [
'el-loading-mask',