Skip to content

Commit

Permalink
fix(list): renders a list with children which is not DOM (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
태재영 authored and Matt Goo committed Feb 19, 2019
1 parent 9c7330b commit e66a267
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
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
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
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.isTrue(wrapper.children().length === 1);
});

0 comments on commit e66a267

Please sign in to comment.