Forráskód Böngészése

Fix Table Bug: body-wrapper should not set style.height when table not set height. (#839)

FuryBean 8 éve
szülő
commit
07cd230674
2 módosított fájl, 6 hozzáadás és 1 törlés
  1. 5 1
      packages/table/src/table-layout.js
  2. 1 0
      test/unit/specs/table.spec.js

+ 5 - 1
packages/table/src/table-layout.js

@@ -9,6 +9,7 @@ class TableLayout {
     this.columns = null;
     this.fit = true;
 
+    this.height = null;
     this.scrollX = false;
     this.scrollY = false;
     this.bodyWidth = null;
@@ -53,6 +54,8 @@ class TableLayout {
       height = Number(height);
     }
 
+    this.height = height;
+
     const el = this.table.$el;
     if (!isNaN(height) && el) {
       el.style.height = height + 'px';
@@ -66,7 +69,8 @@ class TableLayout {
     const { headerWrapper } = this.table.$refs;
     if (!headerWrapper) return;
     const headerHeight = this.headerHeight = headerWrapper.offsetHeight;
-    const bodyHeight = this.bodyHeight = height - headerHeight;
+    const bodyHeight = height - headerHeight;
+    if (this.height !== null && !isNaN(this.height)) this.bodyHeight = bodyHeight;
     this.fixedBodyHeight = this.scrollX ? bodyHeight - this.gutterWidth : bodyHeight;
     this.viewportHeight = this.scrollX ? height - this.gutterWidth : height;
   }

+ 1 - 0
test/unit/specs/table.spec.js

@@ -441,6 +441,7 @@ describe('Table', () => {
         expect(toArray(vm.$el.querySelectorAll('.el-table__fixed-right th:not(.is-hidden)'))
           .map(node => node.textContent))
           .to.eql(['test2']);
+        expect(vm.$el.querySelector('.el-table__body-wrapper').style.height).to.equal('');
         destroyVM(vm);
         done();
       }, DELAY);