Table: fix chrome crash when set thead css display to none (#16956)

pull/17033/head
luckyCao 2019-08-14 10:52:47 +08:00 committed by hetech
parent a907d3922b
commit 75f0eb81ab
1 changed files with 17 additions and 1 deletions

View File

@ -95,8 +95,13 @@ class TableLayout {
this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
if (this.showHeader && !headerWrapper) return;
// fix issue (https://github.com/ElemeFE/element/pull/16956)
const headerTrElm = headerWrapper.querySelector('.el-table__header tr');
const noneHeader = this.headerDisplayNone(headerTrElm);
const headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
if (this.showHeader && headerWrapper.offsetWidth > 0 && (this.table.columns || []).length > 0 && headerHeight < 2) {
if (this.showHeader && !noneHeader && headerWrapper.offsetWidth > 0 && (this.table.columns || []).length > 0 && headerHeight < 2) {
return Vue.nextTick(() => this.updateElsHeight());
}
const tableHeight = this.tableHeight = this.table.$el.clientHeight;
@ -113,6 +118,17 @@ class TableLayout {
this.notifyObservers('scrollable');
}
headerDisplayNone(elm) {
let headerChild = elm;
while (headerChild.tagName !== 'DIV') {
if (getComputedStyle(headerChild).display === 'none') {
return true;
}
headerChild = headerChild.parentElement;
}
return false;
}
updateColumnsWidth() {
if (Vue.prototype.$isServer) return;
const fit = this.fit;