mirror of https://github.com/ElemeFE/element
Table: fix chrome crash when set thead css display to none (#16956)
parent
a907d3922b
commit
75f0eb81ab
|
@ -95,8 +95,13 @@ class TableLayout {
|
||||||
this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
|
this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
|
||||||
|
|
||||||
if (this.showHeader && !headerWrapper) return;
|
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;
|
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());
|
return Vue.nextTick(() => this.updateElsHeight());
|
||||||
}
|
}
|
||||||
const tableHeight = this.tableHeight = this.table.$el.clientHeight;
|
const tableHeight = this.tableHeight = this.table.$el.clientHeight;
|
||||||
|
@ -113,6 +118,17 @@ class TableLayout {
|
||||||
this.notifyObservers('scrollable');
|
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() {
|
updateColumnsWidth() {
|
||||||
if (Vue.prototype.$isServer) return;
|
if (Vue.prototype.$isServer) return;
|
||||||
const fit = this.fit;
|
const fit = this.fit;
|
||||||
|
|
Loading…
Reference in New Issue