mirror of https://github.com/ElemeFE/element
				
				
				
			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.lockpull/6969/head
							parent
							
								
									4609154475
								
							
						
					
					
						commit
						8fc973c51a
					
				| 
						 | 
					@ -855,7 +855,7 @@
 | 
				
			||||||
| --------------------- | ---------------------------------------- | --------------------------- | ---- | ----- |
 | 
					| --------------------- | ---------------------------------------- | --------------------------- | ---- | ----- |
 | 
				
			||||||
| data                  | 展示数据                                     | array                       | —    | —     |
 | 
					| data                  | 展示数据                                     | array                       | —    | —     |
 | 
				
			||||||
| empty-text            | 内容为空的时候展示的文本                             | String                      | —    | —     |
 | 
					| empty-text            | 内容为空的时候展示的文本                             | String                      | —    | —     |
 | 
				
			||||||
| node-key              | 每个树节点用来作为唯一标识的属性,整颗树应该是唯一的               | String                      | —    | —     |
 | 
					| node-key              | 每个树节点用来作为唯一标识的属性,整棵树应该是唯一的               | String                      | —    | —     |
 | 
				
			||||||
| props                 | 配置选项,具体看下表                               | object                      | —    | —     |
 | 
					| props                 | 配置选项,具体看下表                               | object                      | —    | —     |
 | 
				
			||||||
| load                  | 加载子树数据的方法                                | function(node, resolve)     | —    | —     |
 | 
					| load                  | 加载子树数据的方法                                | function(node, resolve)     | —    | —     |
 | 
				
			||||||
| render-content        | 树节点的内容区的渲染 Function                      | Function(h, { node }        | —    | —     |
 | 
					| render-content        | 树节点的内容区的渲染 Function                      | Function(h, { node }        | —    | —     |
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,21 +19,21 @@ LoadingConstructor.prototype.originalPosition = '';
 | 
				
			||||||
LoadingConstructor.prototype.originalOverflow = '';
 | 
					LoadingConstructor.prototype.originalOverflow = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LoadingConstructor.prototype.close = function() {
 | 
					LoadingConstructor.prototype.close = function() {
 | 
				
			||||||
  if (this.fullscreen && this.originalOverflow !== 'hidden') {
 | 
					 | 
				
			||||||
    document.body.style.overflow = this.originalOverflow;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if (this.fullscreen || this.body) {
 | 
					 | 
				
			||||||
    document.body.style.position = this.originalPosition;
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    this.target.style.position = this.originalPosition;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if (this.fullscreen) {
 | 
					  if (this.fullscreen) {
 | 
				
			||||||
    fullscreenLoading = undefined;
 | 
					    fullscreenLoading = undefined;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  this.$on('after-leave', _ => {
 | 
					  this.$on('after-leave', _ => {
 | 
				
			||||||
    this.$el &&
 | 
					    if (this.fullscreen && this.originalOverflow !== 'hidden') {
 | 
				
			||||||
    this.$el.parentNode &&
 | 
					      document.body.style.overflow = this.originalOverflow;
 | 
				
			||||||
    this.$el.parentNode.removeChild(this.$el);
 | 
					    }
 | 
				
			||||||
 | 
					    if (this.fullscreen || this.body) {
 | 
				
			||||||
 | 
					      document.body.style.position = this.originalPosition;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      this.target.style.position = this.originalPosition;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (this.$el && this.$el.parentNode) {
 | 
				
			||||||
 | 
					      this.$el.parentNode.removeChild(this.$el);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    this.$destroy();
 | 
					    this.$destroy();
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  this.visible = false;
 | 
					  this.visible = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,7 +184,7 @@ describe('Loading', () => {
 | 
				
			||||||
      expect(loadingInstance.visible).to.false;
 | 
					      expect(loadingInstance.visible).to.false;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('target', () => {
 | 
					    it('target', done => {
 | 
				
			||||||
      vm = createVue({
 | 
					      vm = createVue({
 | 
				
			||||||
        template: `
 | 
					        template: `
 | 
				
			||||||
        <div class="loading-container"></div>
 | 
					        <div class="loading-container"></div>
 | 
				
			||||||
| 
						 | 
					@ -192,8 +192,14 @@ describe('Loading', () => {
 | 
				
			||||||
      }, true);
 | 
					      }, true);
 | 
				
			||||||
      loadingInstance = Loading({ target: '.loading-container' });
 | 
					      loadingInstance = Loading({ target: '.loading-container' });
 | 
				
			||||||
      let mask = document.querySelector('.el-loading-mask');
 | 
					      let mask = document.querySelector('.el-loading-mask');
 | 
				
			||||||
 | 
					      let container = document.querySelector('.loading-container');
 | 
				
			||||||
      expect(mask).to.exist;
 | 
					      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', () => {
 | 
					    it('body', () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue