File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
packages/material-ui/src/ListItemText Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ function ListItemText(props, context) {
4747 } = props ;
4848 const { dense } = context ;
4949
50- let primary = primaryProp || children ;
51- if ( primary && ! disableTypography ) {
50+ let primary = primaryProp != null ? primaryProp : children ;
51+ if ( primary != null && ! disableTypography ) {
5252 primary = (
5353 < Typography
5454 variant = "subheading"
@@ -61,7 +61,7 @@ function ListItemText(props, context) {
6161 }
6262
6363 let secondary = secondaryProp ;
64- if ( secondary && ! disableTypography ) {
64+ if ( secondary != null && ! disableTypography ) {
6565 secondary = (
6666 < Typography
6767 variant = "body1"
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ describe('<ListItemText />', () => {
6363 const wrapper = shallow ( < ListItemText > { primary } </ ListItemText > ) ;
6464 assert . strictEqual ( wrapper . contains ( primary ) , true , 'should find the node' ) ;
6565 } ) ;
66+
67+ it ( 'should read 0 as primary' , ( ) => {
68+ const wrapper = shallow ( < ListItemText primary = { 0 } /> ) ;
69+ assert . strictEqual ( wrapper . childAt ( 0 ) . type ( ) , Typography ) ;
70+ } ) ;
6671 } ) ;
6772
6873 describe ( 'prop: secondary' , ( ) => {
@@ -91,6 +96,11 @@ describe('<ListItemText />', () => {
9196 const wrapper = shallow ( < ListItemText secondary = { secondary } /> ) ;
9297 assert . strictEqual ( wrapper . contains ( secondary ) , true , 'should find the node' ) ;
9398 } ) ;
99+
100+ it ( 'should read 0 as secondary' , ( ) => {
101+ const wrapper = shallow ( < ListItemText secondary = { 0 } /> ) ;
102+ assert . strictEqual ( wrapper . childAt ( 0 ) . type ( ) , Typography ) ;
103+ } ) ;
94104 } ) ;
95105
96106 describe ( 'prop: disableTypography' , ( ) => {
You can’t perform that action at this time.
0 commit comments