Commit 07cd2306 authored by FuryBean's avatar FuryBean Committed by cinwell.li

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

parent f013d6eb
...@@ -9,6 +9,7 @@ class TableLayout { ...@@ -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 { ...@@ -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 { ...@@ -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;
} }
......
...@@ -441,6 +441,7 @@ describe('Table', () => { ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment