Skip to content

Commit

Permalink
Fix bug: IE do not support “new Event” object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tina C Lin (RD-TW) committed May 26, 2017
1 parent 83cc299 commit a929810
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Table extends PureComponent {
useFixedHeader: false
};

customEvent = null;

mainTable = null;

state = this.getInitState();
Expand Down Expand Up @@ -84,6 +86,13 @@ class Table extends PureComponent {
componentDidMount() {
const { getTableHeight, getTableWidth } = this.actions;
window.addEventListener('resize', getTableHeight);
if (document.createEvent) {
// IE version
this.customEvent = document.createEvent('Event');
this.customEvent.initEvent('checkWidth', true, true);
} else {
this.customEvent = new Event('checkWidth');
}
window.addEventListener('checkWidth', getTableWidth);
getTableHeight();
}
Expand All @@ -108,7 +117,7 @@ class Table extends PureComponent {
// Issue: Page has no vertical scrollbar at begin, but appears the scrollbar after expanding A table,
// and B table width also displays horizontal scrollbar.
// Solution: Add this action to check other tables size in the same page.
window.dispatchEvent(new Event('checkWidth'));
window.dispatchEvent(this.customEvent);
}
}

Expand Down Expand Up @@ -257,6 +266,8 @@ class Table extends PureComponent {
delete props.maxHeight;
delete props.rowClassName;
delete props.onRowClick;
delete props.emptyText;
delete props.showHeader;

return (
<div
Expand Down

0 comments on commit a929810

Please sign in to comment.