Merge pull request #2851 from leptos-rs/2850

Fix nested routing/related issues
This commit is contained in:
Greg Johnston 2024-08-16 20:17:42 -04:00 committed by GitHub
commit 0793d56648
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 31 deletions

View file

@ -364,6 +364,15 @@ where
state: <HtmlElement<E, At, Ch, Dom> as Render<Dom>>::State,
}
impl<E, At, Ch> Drop for RegisteredMetaTagState<E, At, Ch>
where
HtmlElement<E, At, Ch, Dom>: Render<Dom>,
{
fn drop(&mut self) {
self.state.unmount();
}
}
fn document_head() -> HtmlHeadElement {
let document = document();
document.head().unwrap_or_else(|| {

View file

@ -443,22 +443,12 @@ impl<At, Ch, R: Renderer> Deref for ElementState<At, Ch, R> {
impl<At, Ch, R> Mountable<R> for ElementState<At, Ch, R>
where
Ch: Mountable<R>,
R: Renderer,
{
fn unmount(&mut self) {
if let Some(children) = self.children.as_mut() {
children.unmount_from_parent();
}
R::remove(self.el.as_ref());
}
fn unmount_from_parent(&mut self) {
if let Some(children) = self.children.as_mut() {
children.unmount_from_parent();
}
}
fn mount(&mut self, parent: &R::Element, marker: Option<&R::Node>) {
R::insert_node(parent, self.el.as_ref(), marker);
}

View file

@ -282,15 +282,6 @@ pub trait Mountable<R: Renderer> {
/// Detaches the view from the DOM.
fn unmount(&mut self);
/// Detaches the view from the DOM, when it is a child of another element that is being
/// unmounted.
///
/// Most elements do not require any action here, but special view types that have additional
/// unmount logic do.
fn unmount_from_parent(&mut self) {
self.unmount();
}
/// Mounts a node to the interface.
fn mount(&mut self, parent: &R::Element, marker: Option<&R::Node>);

View file

@ -27,8 +27,6 @@ macro_rules! render_primitive {
self.0.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,

View file

@ -131,8 +131,6 @@ where
self.node.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,
@ -234,8 +232,6 @@ impl<R: Renderer> Mountable<R> for StringState<R> {
self.node.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,
@ -328,8 +324,6 @@ impl<R: Renderer> Mountable<R> for RcStrState<R> {
self.node.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,
@ -433,8 +427,6 @@ impl<R: Renderer> Mountable<R> for ArcStrState<R> {
self.node.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,
@ -538,8 +530,6 @@ impl<'a, R: Renderer> Mountable<R> for CowStrState<'a, R> {
self.node.unmount()
}
fn unmount_from_parent(&mut self) {}
fn mount(
&mut self,
parent: &<R as Renderer>::Element,