LoadingL optimize the close process (#6966)

* Remove useless parameters

* Remove useless parameters

* [Tree docs] Modify typos

* [Loading] Optimize the close process

* Optimize the close process

* Revert the yarn.lock

* Update yarn.lock
pull/6969/head
Hejx 心流 2017-09-12 11:20:02 +08:00 committed by 杨奕
parent 4609154475
commit 8fc973c51a
3 changed files with 20 additions and 14 deletions

View File

@ -855,7 +855,7 @@
| --------------------- | ---------------------------------------- | --------------------------- | ---- | ----- |
| data | 展示数据 | array | — | — |
| empty-text | 内容为空的时候展示的文本 | String | — | — |
| node-key | 每个树节点用来作为唯一标识的属性,整树应该是唯一的 | String | — | — |
| node-key | 每个树节点用来作为唯一标识的属性,整树应该是唯一的 | String | — | — |
| props | 配置选项,具体看下表 | object | — | — |
| load | 加载子树数据的方法 | function(node, resolve) | — | — |
| render-content | 树节点的内容区的渲染 Function | Function(h, { node } | — | — |

View File

@ -19,6 +19,10 @@ LoadingConstructor.prototype.originalPosition = '';
LoadingConstructor.prototype.originalOverflow = '';
LoadingConstructor.prototype.close = function() {
if (this.fullscreen) {
fullscreenLoading = undefined;
}
this.$on('after-leave', _ => {
if (this.fullscreen && this.originalOverflow !== 'hidden') {
document.body.style.overflow = this.originalOverflow;
}
@ -27,13 +31,9 @@ LoadingConstructor.prototype.close = function() {
} else {
this.target.style.position = this.originalPosition;
}
if (this.fullscreen) {
fullscreenLoading = undefined;
}
this.$on('after-leave', _ => {
this.$el &&
this.$el.parentNode &&
if (this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el);
}
this.$destroy();
});
this.visible = false;

View File

@ -184,7 +184,7 @@ describe('Loading', () => {
expect(loadingInstance.visible).to.false;
});
it('target', () => {
it('target', done => {
vm = createVue({
template: `
<div class="loading-container"></div>
@ -192,8 +192,14 @@ describe('Loading', () => {
}, true);
loadingInstance = Loading({ target: '.loading-container' });
let mask = document.querySelector('.el-loading-mask');
let container = document.querySelector('.loading-container');
expect(mask).to.exist;
expect(mask.parentNode).to.equal(document.querySelector('.loading-container'));
expect(mask.parentNode).to.equal(container);
loadingInstance.close();
setTimeout(() => {
expect(container.style.position).to.equal('relative');
done();
}, 200);
});
it('body', () => {