Skip to content

Commit

Permalink
Fix bug when transforming empty checklist items
Browse files Browse the repository at this point in the history
Closes GH-9.
Closes Gh-8.
  • Loading branch information
Sarah-Seo authored and wooorm committed Dec 17, 2016
1 parent 30bc081 commit abdddcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/handlers/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function listItem(h, node, parent) {
var props = {};

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

Expand Down
19 changes: 19 additions & 0 deletions test/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,24 @@ test('ListItem', function (t) {
'should support `listItem`s without children'
);

t.deepEqual(
to(u('listItem', {checked: true}, [])),
u('element', {tagName: 'li', properties: {className: ['task-list-item']}}, [
u('text', '\n'),
u('element', {tagName: 'p', properties: {}}, [
u('element', {
tagName: 'input',
properties: {
type: 'checkbox',
checked: true,
disabled: true
}
}, [])
]),
u('text', '\n')
]),
'should support checkboxes in `listItem`s without children'
);

t.end();
});

0 comments on commit abdddcd

Please sign in to comment.