mirror of
https://github.com/leptos-rs/leptos.git
synced 2026-11-30 09:44:33 -06:00
fix: reset hydration marker to NextChild after closing branch markers
This commit is contained in:
@@ -211,6 +211,6 @@ pub fn About() -> impl IntoView {
|
||||
pub fn Counter() -> impl IntoView {
|
||||
let count = RwSignal::new(0);
|
||||
view! {
|
||||
<button class="counter" on:click=move |_| *count.write() += 1>{count}</button>
|
||||
<button class="counter" on:click=move |_| *count.write() += 1>"Click Me: "{count}</button>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +575,10 @@ impl RenderHtml for AnyView {
|
||||
#[cfg(feature = "hydrate")]
|
||||
{
|
||||
if FROM_SERVER {
|
||||
(self.hydrate_from_server)(self.value, cursor, position)
|
||||
let state =
|
||||
(self.hydrate_from_server)(self.value, cursor, position);
|
||||
super::close_branch_marker(position);
|
||||
state
|
||||
} else {
|
||||
panic!(
|
||||
"hydrating AnyView from inside a ViewTemplate is not \
|
||||
@@ -603,6 +606,7 @@ impl RenderHtml for AnyView {
|
||||
{
|
||||
let state =
|
||||
(self.hydrate_async)(self.value, cursor, position).await;
|
||||
super::close_branch_marker(position);
|
||||
state
|
||||
}
|
||||
#[cfg(not(feature = "hydrate"))]
|
||||
|
||||
@@ -411,14 +411,16 @@ where
|
||||
cursor: &Cursor,
|
||||
position: &PositionState,
|
||||
) -> Self::State {
|
||||
match self {
|
||||
let state = match self {
|
||||
Either::Left(left) => {
|
||||
Either::Left(left.hydrate::<FROM_SERVER>(cursor, position))
|
||||
}
|
||||
Either::Right(right) => {
|
||||
Either::Right(right.hydrate::<FROM_SERVER>(cursor, position))
|
||||
}
|
||||
}
|
||||
};
|
||||
super::close_branch_marker(position);
|
||||
state
|
||||
}
|
||||
|
||||
async fn hydrate_async(
|
||||
@@ -426,14 +428,16 @@ where
|
||||
cursor: &Cursor,
|
||||
position: &PositionState,
|
||||
) -> Self::State {
|
||||
match self {
|
||||
let state = match self {
|
||||
Either::Left(left) => {
|
||||
Either::Left(left.hydrate_async(cursor, position).await)
|
||||
}
|
||||
Either::Right(right) => {
|
||||
Either::Right(right.hydrate_async(cursor, position).await)
|
||||
}
|
||||
}
|
||||
};
|
||||
super::close_branch_marker(position);
|
||||
state
|
||||
}
|
||||
|
||||
fn into_owned(self) -> Self::Owned {
|
||||
@@ -964,6 +968,7 @@ macro_rules! tuples {
|
||||
[<EitherOf $num>]::$ty(this.hydrate::<FROM_SERVER>(cursor, position))
|
||||
})*
|
||||
};
|
||||
$crate::view::close_branch_marker(position);
|
||||
|
||||
Self::State { state }
|
||||
}
|
||||
@@ -978,6 +983,7 @@ macro_rules! tuples {
|
||||
[<EitherOf $num>]::$ty(this.hydrate_async(cursor, position).await)
|
||||
})*
|
||||
};
|
||||
$crate::view::close_branch_marker(position);
|
||||
|
||||
Self::State { state }
|
||||
}
|
||||
|
||||
@@ -86,6 +86,19 @@ impl MarkBranch for StreamBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn close_branch_marker(position: &PositionState) {
|
||||
#[cfg(feature = "mark_branches")]
|
||||
if position.get() == Position::NextChildAfterText {
|
||||
position.set(Position::NextChild);
|
||||
}
|
||||
#[cfg(not(feature = "mark_branches"))]
|
||||
{
|
||||
_ = position;
|
||||
}
|
||||
}
|
||||
|
||||
/// The `RenderHtml` trait allows rendering something to HTML, and transforming
|
||||
/// that HTML into an interactive interface.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user