File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,16 @@ var all = require('../all');
1010function listItem ( h , node , parent ) {
1111 var children = node . children ;
1212 var head = children [ 0 ] ;
13- var single = ( ! parent || ! parent . loose ) && head && head . children && children . length === 1 ;
14- var result = all ( h , single ? head : node ) ;
15- var container ;
1613 var props = { } ;
14+ var single = false ;
15+ var result ;
16+ var container ;
17+
18+ if ( ( ! parent || ! parent . loose ) && children . length === 1 && head . type === 'paragraph' ) {
19+ single = true ;
20+ }
21+
22+ result = all ( h , single ? head : node ) ;
1723
1824 if ( typeof node . checked === 'boolean' ) {
1925 if ( ! single && ( ! head || head . type !== 'paragraph' ) ) {
Original file line number Diff line number Diff line change @@ -128,5 +128,29 @@ test('ListItem', function (t) {
128128 'should support checkboxes in `listItem`s without children'
129129 ) ;
130130
131+ t . deepEqual (
132+ to ( u ( 'listItem' , [
133+ u ( 'list' , { ordered : false } , [
134+ u ( 'listItem' , [
135+ u ( 'paragraph' , [
136+ u ( 'text' , 'Alpha' )
137+ ] )
138+ ] )
139+ ] )
140+ ] ) ) ,
141+ u ( 'element' , { tagName : 'li' , properties : { } } , [
142+ u ( 'text' , '\n' ) ,
143+ u ( 'element' , { tagName : 'ul' , properties : { } } , [
144+ u ( 'text' , '\n' ) ,
145+ u ( 'element' , { tagName : 'li' , properties : { } } , [
146+ u ( 'text' , 'Alpha' )
147+ ] ) ,
148+ u ( 'text' , '\n' )
149+ ] ) ,
150+ u ( 'text' , '\n' )
151+ ] ) ,
152+ 'should support lists in `listItem`s'
153+ ) ;
154+
131155 t . end ( ) ;
132156} ) ;
You can’t perform that action at this time.
0 commit comments