Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/table/src/table-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ class TableLayout {
this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;

if (this.showHeader && !headerWrapper) return;

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;
Expand All @@ -113,6 +117,17 @@ class TableLayout {
this.notifyObservers('scrollable');
}

headerDisplayNone(elm) {
ziyoung marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand Down