Skip to content

Commit bb9c370

Browse files
authored
Fix empty table bug (henrybuilt#2)
* Update deps * Fix empty node bug * Fix empty node style
1 parent 0ebd83e commit bb9c370

File tree

8 files changed

+5978
-51
lines changed

8 files changed

+5978
-51
lines changed

.eslintrc

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
"node": true,
66
"es6": true
77
},
8-
"ecmaFeatures": {
9-
"modules": true
8+
"parserOptions": {
9+
"ecmaVersion": 6,
10+
"sourceType": "module",
11+
"ecmaFeatures": {
12+
"jsx": true
13+
}
1014
},
1115
"rules": {
1216
"no-bitwise": 2,

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
.eslintrc
99
npm-debug.log
1010
lib
11+
examples
12+
webpack.config.js

dist/index.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,13 @@
319319
cell.style.width = width + 'px';
320320
cell.style.minWidth = width + 'px';
321321

322-
if (this.stickyCorner.firstChild.firstChild.childNodes[c]) {
323-
cell = this.stickyCorner.firstChild.firstChild.childNodes[c];
322+
var fixedColumnsHeader = this.stickyCorner.firstChild.firstChild;
323+
if (fixedColumnsHeader && fixedColumnsHeader.childNodes[c]) {
324+
cell = fixedColumnsHeader.childNodes[c];
324325
cell.style.width = width + 'px';
325326
cell.style.minWidth = width + 'px';
326327

327-
cell = this.stickyColumn.firstChild.firstChild.childNodes[c];
328+
cell = fixedColumnsHeader.childNodes[c];
328329
cell.style.width = width + 'px';
329330
cell.style.minWidth = width + 'px';
330331

@@ -393,19 +394,11 @@
393394

394395
return stickyCorner;
395396
}
396-
}, {
397-
key: 'getStyle',
398-
value: function getStyle(node) {
399-
var browserSupportsComputedStyle = typeof getComputedStyle !== 'undefined';
400-
401-
return browserSupportsComputedStyle ? getComputedStyle(node, null) : node.currentStyle;
402-
}
403397
}, {
404398
key: 'getSize',
405399
value: function getSize(node) {
406-
var nodeStyle = this.getStyle(node);
407-
var width = node.getBoundingClientRect().width;
408-
var height = node.getBoundingClientRect().height;
400+
var width = node ? node.getBoundingClientRect().width : 0;
401+
var height = node ? node.getBoundingClientRect().height : 0;
409402

410403
return { width: width, height: height };
411404
}

examples/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { StickyTable, Table, Row, Cell } from '../src/index';
1111
class Example extends Component {
1212
state = {
1313
colsCount: 50,
14-
rowsCount: 30,
14+
rowsCount: 1,
1515
renderTable: true,
16-
locked: 2
16+
locked: 1
1717
};
1818

1919
handleLocked = (inc) => {

0 commit comments

Comments
 (0)