Skip to content

Commit abdddcd

Browse files
Sarah-Seowooorm
authored andcommitted
Fix bug when transforming empty checklist items
Closes GH-9. Closes Gh-8.
1 parent 30bc081 commit abdddcd

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/handlers/list-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function listItem(h, node, parent) {
1616
var props = {};
1717

1818
if (typeof node.checked === 'boolean') {
19-
if (!single && head.type !== 'paragraph') {
19+
if (!single && (!head || head.type !== 'paragraph')) {
2020
result.unshift(h(null, 'p', []));
2121
}
2222

test/list-item.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,24 @@ test('ListItem', function (t) {
109109
'should support `listItem`s without children'
110110
);
111111

112+
t.deepEqual(
113+
to(u('listItem', {checked: true}, [])),
114+
u('element', {tagName: 'li', properties: {className: ['task-list-item']}}, [
115+
u('text', '\n'),
116+
u('element', {tagName: 'p', properties: {}}, [
117+
u('element', {
118+
tagName: 'input',
119+
properties: {
120+
type: 'checkbox',
121+
checked: true,
122+
disabled: true
123+
}
124+
}, [])
125+
]),
126+
u('text', '\n')
127+
]),
128+
'should support checkboxes in `listItem`s without children'
129+
);
130+
112131
t.end();
113132
});

0 commit comments

Comments
 (0)