Skip to content

Commit

Permalink
Fix to not crash on empty text nodes
Browse files Browse the repository at this point in the history
Closes GH-494.
  • Loading branch information
wooorm committed Oct 21, 2020
1 parent ce56761 commit c3dc5ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ module.exports = {
}

function TextRenderer(props) {
const children = props.children || ''
/* istanbul ignore next - `span` is a fallback for old React. */
return supportsStringRender ? props.children : createElement('span', null, props.children)
return supportsStringRender ? children : createElement('span', null, children)
}

function Root(props) {
Expand Down
7 changes: 7 additions & 0 deletions test/react-markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,3 +886,10 @@ test('should pass `node` as prop to all non-tag/non-fragment renderers', () => {
const component = renderer.create(<Markdown renderers={{heading}} children={input} />)
expect(component.toJSON()).toBe("So, headers... they're cool")
})

test('should support formatting at the start of a GFM tasklist (GH-494)', () => {
const input = '- [ ] *a*'
const actual = renderHTML(<Markdown children={input} plugins={[gfm]} />)
const expected = '<ul><li><input type="checkbox" readonly=""/><em>a</em></li></ul>'
expect(actual).toEqual(expected)
})

0 comments on commit c3dc5ee

Please sign in to comment.