{"action":"opened","issue":{"url":"https://api.github.com/repos/snabbdom/snabbdom/issues/395","repository_url":"https://api.github.com/repos/snabbdom/snabbdom","labels_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/395/comments","events_url":"https://api.github.com/repos/snabbdom/snabbdom/issues/395/events","html_url":"https://github.com/snabbdom/snabbdom/issues/395","id":356457026,"node_id":"MDU6SXNzdWUzNTY0NTcwMjY=","number":395,"title":"Error: insertBefore when reusing vnodes","user":{"login":"jvanbruegge","id":1529052,"node_id":"MDQ6VXNlcjE1MjkwNTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1529052?v=4","gravatar_id":"","url":"https://api.github.com/users/jvanbruegge","html_url":"https://github.com/jvanbruegge","followers_url":"https://api.github.com/users/jvanbruegge/followers","following_url":"https://api.github.com/users/jvanbruegge/following{/other_user}","gists_url":"https://api.github.com/users/jvanbruegge/gists{/gist_id}","starred_url":"https://api.github.com/users/jvanbruegge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvanbruegge/subscriptions","organizations_url":"https://api.github.com/users/jvanbruegge/orgs","repos_url":"https://api.github.com/users/jvanbruegge/repos","events_url":"https://api.github.com/users/jvanbruegge/events{/privacy}","received_events_url":"https://api.github.com/users/jvanbruegge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-03T10:57:09Z","updated_at":"2018-09-03T10:57:09Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Reproducable example:\r\n```js\r\nvar sharedNode = h('div', {}, 'Selected');\r\nvar vnode1 = h('div', [\r\n  h('div', {}, ['One']),\r\n  h('div', {}, ['Two']),\r\n  h('div', {}, [sharedNode]),\r\n]);\r\nvar vnode2 = h('div', [\r\n  h('div', {}, ['One']),\r\n  h('div', {}, [sharedNode]),\r\n  h('div', {}, ['Three']),\r\n]);\r\npatch(vnode0, vnode1);\r\npatch(vnode1, vnode2);\r\n```\r\nThis example crashes on the second `patch`.\r\nThe reason is that when the actual DOM node for `sharedNode` on position two is created, it assigns it as `vnode.elm`. The `vnode` is still that same `sharedNode`, that the third node still has a reference to (as it is not yet processed). When the third node gets created, it tries to do `insertBefore` with `vnode.elm` which is **not** the actual elm from the last patch (on position 3), but the new dom node of `sharedNode` created in **this** patch. Thus the `insertBefore` crashes as the element is not a child of the parent of the third node.\r\n\r\nThis is the cause for https://github.com/cyclejs/cyclejs/issues/713\r\n\r\nI am not sure what is the best way to solve this."}}
{"actor":{"display_login":"jvanbruegge"}}