File tree 2 files changed +33
-3
lines changed
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');
10
10
function listItem ( h , node , parent ) {
11
11
var children = node . children ;
12
12
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 ;
16
13
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 ) ;
17
23
18
24
if ( typeof node . checked === 'boolean' ) {
19
25
if ( ! single && ( ! head || head . type !== 'paragraph' ) ) {
Original file line number Diff line number Diff line change @@ -128,5 +128,29 @@ test('ListItem', function (t) {
128
128
'should support checkboxes in `listItem`s without children'
129
129
) ;
130
130
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
+
131
155
t . end ( ) ;
132
156
} ) ;
You can’t perform that action at this time.
0 commit comments