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 {
|
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;
|
let mut replace_state = MountState::Detached;
|
||||||
swap(&mut replace_state, &mut self.state);
|
swap(&mut replace_state, &mut self.state);
|
||||||
match replace_state {
|
match replace_state {
|
||||||
MountState::Mounted(this) => {
|
MountState::Mounted(this) => {
|
||||||
(this.destroyer)();
|
(this.destroyer)();
|
||||||
this.node_ref.get().and_then(|node| {
|
this.node_ref.get().and_then(|node| node.next_sibling())
|
||||||
let next_sibling = node.next_sibling();
|
|
||||||
parent
|
|
||||||
.remove_child(&node)
|
|
||||||
.expect("can't remove the component");
|
|
||||||
next_sibling
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
use super::{VChild, VComp, VDiff, VList, VTag, VText};
|
use super::{VChild, VComp, VDiff, VList, VTag, VText};
|
||||||
use crate::html::{Component, Renderable};
|
use crate::html::{Component, Renderable};
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
use log::warn;
|
||||||
use std::cmp::PartialEq;
|
use std::cmp::PartialEq;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
@ -39,9 +40,9 @@ impl VDiff for VNode {
|
|||||||
VNode::VList(ref mut vlist) => vlist.detach(parent),
|
VNode::VList(ref mut vlist) => vlist.detach(parent),
|
||||||
VNode::VRef(ref node) => {
|
VNode::VRef(ref node) => {
|
||||||
let sibling = node.next_sibling();
|
let sibling = node.next_sibling();
|
||||||
parent
|
if parent.remove_child(node).is_err() {
|
||||||
.remove_child(node)
|
warn!("Node not found to remove VRef");
|
||||||
.expect("can't remove node by VRef");
|
}
|
||||||
sibling
|
sibling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user