mirror of https://github.com/ElemeFE/element
parent
4ed7ac6719
commit
e1990a70d3
|
@ -136,7 +136,12 @@ export default {
|
||||||
}
|
}
|
||||||
this.prevActiveElement = document.activeElement;
|
this.prevActiveElement = document.activeElement;
|
||||||
} else {
|
} else {
|
||||||
if (!this.closed) this.$emit('close');
|
if (!this.closed) {
|
||||||
|
this.$emit('close');
|
||||||
|
if (this.destroyOnClose === true) {
|
||||||
|
this.rendered = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.prevActiveElement) {
|
if (this.prevActiveElement) {
|
||||||
this.prevActiveElement.focus();
|
this.prevActiveElement.focus();
|
||||||
|
|
|
@ -132,6 +132,30 @@ describe('Drawer', () => {
|
||||||
expect(vm.$el.querySelector('.el-drawer__body')).not.to.exist;
|
expect(vm.$el.querySelector('.el-drawer__body')).not.to.exist;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should destroy every child by visible change when destroy-on-close flag is true', async() => {
|
||||||
|
vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-drawer :title='title' :visible='visible' :append-to-body='true' :destroy-on-close='true' ref='drawer'>
|
||||||
|
<span>${content}</span>
|
||||||
|
</el-drawer>
|
||||||
|
`,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
visible: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitImmediate();
|
||||||
|
expect(vm.$el.querySelector('.el-drawer__body span').textContent).to.equal(
|
||||||
|
content
|
||||||
|
);
|
||||||
|
vm.visible = false;
|
||||||
|
await wait(400);
|
||||||
|
expect(vm.$el.querySelector('.el-drawer__body')).not.to.exist;
|
||||||
|
});
|
||||||
|
|
||||||
it('should close dialog by clicking the close button', async() => {
|
it('should close dialog by clicking the close button', async() => {
|
||||||
vm = createVue({
|
vm = createVue({
|
||||||
template: `
|
template: `
|
||||||
|
|
Loading…
Reference in New Issue