Skip to content

Commit

Permalink
Merge pull request glittershark#336 from apprennet/fix-null-columns
Browse files Browse the repository at this point in the history
checking if !th in thead.jsx
  • Loading branch information
glittershark authored Nov 19, 2016
2 parents ede45ad + 4fdfeec commit 4cb57c1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/reactable.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ window.ReactDOM["default"] = window.ReactDOM;
var columns = [];
_react['default'].Children.forEach(component.props.children, function (th) {
var column = {};
if (!th) return;
if (typeof th.props !== 'undefined') {
column.props = (0, _libFilter_props_from.filterPropsFrom)(th.props);

Expand Down
1 change: 1 addition & 0 deletions lib/reactable/thead.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var Thead = (function (_React$Component) {
var columns = [];
_react2['default'].Children.forEach(component.props.children, function (th) {
var column = {};
if (!th) return;
if (typeof th.props !== 'undefined') {
column.props = (0, _libFilter_props_from.filterPropsFrom)(th.props);

Expand Down
1 change: 1 addition & 0 deletions src/reactable/thead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class Thead extends React.Component {
let columns = [];
React.Children.forEach(component.props.children, th => {
var column = {};
if (!th) return;
if (typeof th.props !== 'undefined') {
column.props = filterPropsFrom(th.props);

Expand Down
20 changes: 20 additions & 0 deletions tests/reactable_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,26 @@ describe('Reactable', function() {
ReactableTestUtils.expectRowText(1, ['', '28', 'Developer']);
});
});

context("when one of the <Th>s is null", function(){
before(function () {
ReactDOM.render(
<Reactable.Table className="table" id="table">
<Reactable.Thead>
<Reactable.Th>Test</Reactable.Th>
{null}
</Reactable.Thead>
</Reactable.Table>,
ReactableTestUtils.testNode()
);
});

after(ReactableTestUtils.resetTestEnvironment);

it('renders the table', function() {
expect($('table#table.table')).to.exist;
});
});
});

describe('Adding a <Tfoot>', function() {
Expand Down

0 comments on commit 4cb57c1

Please sign in to comment.