651: Fix VNode orphaning inside of VTags r=jstarry a=hgzimmerman

Fixes https://github.com/yewstack/yew/issues/643

VTags now recursively detach their children when they are detached themselves. This means that Components nested within `<div>`s or other elements will now properly run their `destroy` function and be dropped by the framework.

Its nice to finally squash a bug that's bothered me for more than a year.

Co-authored-by: Henry Zimmerman <zimhen7@gmail.com>
This commit is contained in:
bors[bot] 2019-09-23 01:31:07 +00:00 committed by GitHub
commit 1375714339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -350,6 +350,12 @@ impl<COMP: Component> VDiff for VTag<COMP> {
.reference
.take()
.expect("tried to remove not rendered VTag from DOM");
// recursively remove its children
self.childs.drain(..).for_each(|mut child| {
child.detach(&node);
});
let sibling = node.next_sibling();
if parent.remove_child(&node).is_err() {
warn!("Node not found to remove VTag");