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

Exception thrown when updating a text node #972

Closed
cjohansen opened this issue Jun 14, 2021 · 0 comments · Fixed by #1062
Closed

Exception thrown when updating a text node #972

cjohansen opened this issue Jun 14, 2021 · 0 comments · Fixed by #1062

Comments

@cjohansen
Copy link

Related t #971. I'm not sure what the intended behavior for text nodes is, but I had hoped this would work:

var el = document.createElement('div');
document.body.appendChild(el);

// Works as expected
var vdom = patch(el, snabbdom.vnode(undefined, {}, [], 'Text', null));

// Throws exception
var vdom2 = patch(vdom, snabbdom.vnode(undefined, {}, [], 'Text 2', null));

The second patch call throws an exception where it tries to do getAttribute on null. Is this even supposed to work?

Changing an h2 to a bare text works:

var vdom = patch(el, snabbdom.vnode("h2", {}, [], 'Text', null));
patch(vdom, snabbdom.vnode(undefined, {}, [], 'Text 2', null));

But the other way around does not:

var vdom = patch(vdom, snabbdom.vnode(undefined, {}, [], 'Text 2', null));
patch(el, snabbdom.vnode("h2", {}, [], 'Text', null));
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 a pull request may close this issue.

1 participant