{"action":"created","issue":{"url":"https://api.github.com/repos/snabbdom/snabbdom/issues/174","repository_url":"https://api.github.com/repos/snabbdom/snabbdom","labels_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/174/comments","events_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/174/events","html_url":"https://github.com/snabbdom/snabbdom/pull/174","id":181308437,"number":174,"title":"Make debugging undefined children easier","user":{"login":"jayrbolton","id":8740476,"avatar_url":"https://avatars.githubusercontent.com/u/8740476?v=3","gravatar_id":"","url":"https://api.github.com/users/jayrbolton","html_url":"https://github.com/jayrbolton","followers_url":"https://api.github.com/users/jayrbolton/followers","following_url":"https://api.github.com/users/jayrbolton/following{/other_user}","gists_url":"https://api.github.com/users/jayrbolton/gists{/gist_id}","starred_url":"https://api.github.com/users/jayrbolton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayrbolton/subscriptions","organizations_url":"https://api.github.com/users/jayrbolton/orgs","repos_url":"https://api.github.com/users/jayrbolton/repos","events_url":"https://api.github.com/users/jayrbolton/events{/privacy}","received_events_url":"https://api.github.com/users/jayrbolton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-06T02:06:38Z","updated_at":"2016-10-07T16:43:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/snabbdom/snabbdom/pulls/174","html_url":"https://github.com/snabbdom/snabbdom/pull/174","diff_url":"https://github.com/snabbdom/snabbdom/pull/174.diff","patch_url":"https://github.com/snabbdom/snabbdom/pull/174.patch"},"body":"I find this error to be a very common case: `Cannot read property 'data' of undefined` which occurs when a child of a vnode is undefined during the patch process.\r\n\r\nYou can never use the stack trace to see where it is coming from in your original code where you construct the tree with `h()` functions. This is because the error arises during the patch process, and no part of the execution path refers to where the `h()` function was originally called. I find this hard to debug\r\n\r\nTo make the stack trace useful for this error, I added a check at the time the `h()` function is called that will throw a type error if any children are undefined. For sparse arrays, I don't have a good type check for those, so instead I filter them into non-sparse arrays.\r\n\r\nExample instances that cause this untraceable error, which can be hard to see just by looking:\r\n\r\n`h('div', [,h('p', 'Hi'])`\r\n\r\n`h('div', ['hello, ', state.greeting] // state.greeting happens to be undefined or null`"},"comment":{"url":"https://api.github.com/repos/snabbdom/snabbdom/issues/comments/252301977","html_url":"https://github.com/snabbdom/snabbdom/pull/174#issuecomment-252301977","issue_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/174","id":252301977,"user":{"login":"jayrbolton","id":8740476,"avatar_url":"https://avatars.githubusercontent.com/u/8740476?v=3","gravatar_id":"","url":"https://api.github.com/users/jayrbolton","html_url":"https://github.com/jayrbolton","followers_url":"https://api.github.com/users/jayrbolton/followers","following_url":"https://api.github.com/users/jayrbolton/following{/other_user}","gists_url":"https://api.github.com/users/jayrbolton/gists{/gist_id}","starred_url":"https://api.github.com/users/jayrbolton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayrbolton/subscriptions","organizations_url":"https://api.github.com/users/jayrbolton/orgs","repos_url":"https://api.github.com/users/jayrbolton/repos","events_url":"https://api.github.com/users/jayrbolton/events{/privacy}","received_events_url":"https://api.github.com/users/jayrbolton/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T16:43:59Z","updated_at":"2016-10-07T16:43:59Z","body":"Yeah, I'm in favor of an early type error rather than ignoring/coercing, as I'd rather find errors than have \"null\" and \"undefined\" silently printed out in apps. I definitely agree about the performance concerns and  was thinking that perhaps a type check could instead go in the VNode() constructor -- I will play around with that approach instead."}}
{"actor":{"display_login":"jayrbolton"}}