mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Merge #651
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:
commit
1375714339
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user