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

pull/842/head
FuryBean 2016-11-05 07:31:18 +08:00 committed by cinwell.li
parent f013d6eb0b
commit 07cd230674
2 changed files with 6 additions and 1 deletions

View File

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

View File

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