Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug which occurs when the heading has no children #34

Merged
merged 2 commits into from
Mar 23, 2017

Conversation

asmsuechan
Copy link
Contributor

Hi. I hit an error TypeError: Cannot read property 'type' of undefined when I write such a markdown below:

# hoge

##

screen shot 2017-03-19 at 23 50 22

screen shot 2017-03-19 at 23 33 27

@coveralls
Copy link

coveralls commented Mar 20, 2017

Coverage Status

Coverage increased (+1.04%) to 100.0% when pulling bdc81f5 on asmsuechan:fix-a-bug into 64a3eb3 on medfreeman:master.

@asmsuechan
Copy link
Contributor Author

Hi, @medfreeman. What do you think?

@medfreeman medfreeman merged commit d00ce1b into medfreeman:master Mar 23, 2017
@medfreeman
Copy link
Owner

Thank you !

@asmsuechan asmsuechan deleted the fix-a-bug branch March 23, 2017 02:57
@thematlin
Copy link

@medfreeman I'm experiencing the same bug. Would it be possible to get this released and published to npm? Would be greatly appreciated.

@leopoldchen
Copy link

leopoldchen commented Jun 7, 2018

@asmsuechan @medfreeman
the solution should be like this

if (heading.children &&
    heading.children.length > 0 &&
    heading.children[0].type === "link_open") 

because heading.children might be null as well

here is an online demo

Just enable the TOC, and type a '#' on a new line, and see the error log in the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants