mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
parent
86af481c0d
commit
bb7c8280a6
@ -161,19 +161,13 @@ enum Reform {
|
||||
}
|
||||
|
||||
impl VDiff for VComp {
|
||||
fn detach(&mut self, parent: &Element) -> Option<Node> {
|
||||
fn detach(&mut self, _parent: &Element) -> Option<Node> {
|
||||
let mut replace_state = MountState::Detached;
|
||||
swap(&mut replace_state, &mut self.state);
|
||||
match replace_state {
|
||||
MountState::Mounted(this) => {
|
||||
(this.destroyer)();
|
||||
this.node_ref.get().and_then(|node| {
|
||||
let next_sibling = node.next_sibling();
|
||||
parent
|
||||
.remove_child(&node)
|
||||
.expect("can't remove the component");
|
||||
next_sibling
|
||||
})
|
||||
this.node_ref.get().and_then(|node| node.next_sibling())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
use super::{VChild, VComp, VDiff, VList, VTag, VText};
|
||||
use crate::html::{Component, Renderable};
|
||||
use cfg_if::cfg_if;
|
||||
use log::warn;
|
||||
use std::cmp::PartialEq;
|
||||
use std::fmt;
|
||||
use std::iter::FromIterator;
|
||||
@ -39,9 +40,9 @@ impl VDiff for VNode {
|
||||
VNode::VList(ref mut vlist) => vlist.detach(parent),
|
||||
VNode::VRef(ref node) => {
|
||||
let sibling = node.next_sibling();
|
||||
parent
|
||||
.remove_child(node)
|
||||
.expect("can't remove node by VRef");
|
||||
if parent.remove_child(node).is_err() {
|
||||
warn!("Node not found to remove VRef");
|
||||
}
|
||||
sibling
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user