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
Unmounting by patch(vnode, null)
documented but not implemented
#461
Comments
I'm using snabbdom@0.7.3 (installed from npm) |
I've also tried the inline example listed in the readme, and this fails too, the same error: https://github.com/snabbdom/snabbdom#inline-example I'm becoming more convinced this is either a bug or a malformed example. Any help would be greatly appreciated please. :) |
Thank you for your interest in snabbdom, @mreinstein. I'm going to try to help you as much as I can. I read your example code and I don't see what part the I'm going to close this but feel free to continue discussion. |
I appreciate the willingness to help! Can you please not close the issue before we've considered it? I think once we look into this you'll see that something is going on.
The purpose of |
This example: It has 2 problems:
The first example in the readme is not usable. |
It seems that the example is not a complete code example. Un-mounting is for the purpose of destroying the app. For example, if it's not a single page app, but only a part of a single page app (sub-app?), then before the parent app "navigates" away from that page, you should destroy the snabbdom sub-app. So it's not something you'd like to do as long as the app is running. From what I've read, your example code seems like it should work fine without that call to If you'd like to open a new issue regarding the documentation, please go ahead. If you'd like to submit a pull request to improve the documentation—even better. That would be appreciated. |
Yes, that is my understanding of it too. I am trying to completely unmount the application, permanently.
I am happy to submit a pull request to fix the documentation, but first I need to see a working example of |
It seems that you're right and Line 289 in 3f85807
Lines 13 to 20 in 3f85807
|
patch(VNode, null)
throws
Yeah I think we have to support null both ways. Patch(null, vnode) should be equivalent of creating a nested document.createElement where you can get the vnode.elm and manually add it somewhere .e.g shadowRoot And the opposite patch(vnode,elm) should completely destruct the tree by removing all event listeners and parent/child references such that the tree could be garbage collected by the js engine. |
I'm not opposed to this, but it belongs in another ticket/issue as a feature request. This issue is specifically a bug report on the existing, broken, documented api for destroying an existing vnode and all of it's children. |
I use something like
to remove an element. It just patches a comment-node into |
I believe this ticket should be labelled as a bug. Also, I hate to be a pest but is there any update/thoughts on this? |
On first look it seems like a non-breaking bug fix. Nothing to report. |
ok, well thanks for the update anyway |
@mightyiam I attempted a fix for this, via #536 Would this work? |
Reviewing #536 I am asking myself what the return value of Line 291 in d4a8640
In light of that, I suggest that this bug be fixed not by adding the missing implementation of the documented API, but by removing the documentation and coming up with a new, additional, API for unmounting a root VNode.
Thinking about it, the only value of that seems to be the running of the Thoughts? |
I think that's reasonable. If we do this we should document the workaround people are using as the "ordained" way of cleaning up ( |
#537 updates README.md as discussed. That said, I think |
patch(VNode, null)
throwspatch(vnode, null)
documented but not implemented
My setup code:
When I click the div, I see the counter increment, but then there's a console error, and I never see the dom get unmounted:
which corresponds to this code from snabbdom:
Any ideas what I'm doing wrong? Or is this a bug in the
destroypatch code?The text was updated successfully, but these errors were encountered: