Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

fix(list): renders a list with children which is not DOM #674

Merged
merged 4 commits into from Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@material/list": "^0.41.0",
"@material/menu-surface": "^0.41.0",
"@material/notched-outline": "^0.41.0",
"@material/radio": "^0.41.0",
"@material/ripple": "^0.41.0",
"@material/select": "^0.40.1",
"@material/snackbar": "^0.43.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function isReactText(element: any): element is React.ReactText {
}

function isListItem(element: any): element is ListItem {
return element.type === ListItem;
return element && element.type === ListItem;
}

export default class List<T extends HTMLElement = HTMLElement> extends React.Component<ListProps<T>, ListState> {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/list/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,14 @@ test('renders a list with a nav tag', () => {
const wrapper = shallow(<List tag='nav'>{children()}</List>);
assert.equal(wrapper.type(), 'nav');
});

test('renders a list with children which is not DOM', () => {
const wrapper = shallow(<List>
{}
{false}
{'text'}
{null}
{undefined}
</List>);
assert.isNotEmpty(wrapper);
});