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

Can't patch document fragment created from a text node #971

Closed
cjohansen opened this issue Jun 12, 2021 · 2 comments · Fixed by #1062
Closed

Can't patch document fragment created from a text node #971

cjohansen opened this issue Jun 12, 2021 · 2 comments · Fixed by #1062

Comments

@cjohansen
Copy link

I'm trying to patch in a text node, using a document fragment:

var patch = snabbdom.init([
  snabbdom.propsModule
]);

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

var fragment = document.createDocumentFragment();
fragment.appendChild(document.createTextNode("Text"));

var vdom = patch(el, snabbdom.toVNode(fragment));

This throws an exception when snabbdom tries to createElement and the vnode sel is an empty string. The changelog mentioned document fragments being supported, but perhaps some other way? Am I doing it wrong?

@jvanbruegge
Copy link
Member

Document fragments should work, but sadly I can't have a deeper look at this at the moment as I am busy the next two weeks

@cjohansen cjohansen changed the title Can't patch document fragment Can't patch document fragment created from a text node Jun 14, 2021
@cjohansen
Copy link
Author

After looking into this some more I realize that the initial report is a little inaccurate. The problem is that calling toVNode with a document fragment created from only a text node creates a vnode that snabbdom can't render.

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.

2 participants