Skip to content

Commit

Permalink
Fixed rebuilding
Browse files Browse the repository at this point in the history
  • Loading branch information
zakstucke committed Oct 22, 2024
1 parent af6a216 commit 0825c8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tachys/src/html/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,11 @@ impl IntoStyle for (Arc<str>, Arc<str>) {
if name != state.1 {
<(Arc<str>, Arc<str>) as IntoStyle>::reset(state);
}
let (style, _prev_name, prev_value) = state;
let (style, prev_name, prev_value) = state;
if value != *prev_value {
Rndr::set_css_property(style, &name, &value);
}
*prev_name = name;
*prev_value = value;
}

Expand Down Expand Up @@ -512,10 +513,11 @@ impl<'a> IntoStyle for (&'a str, &'a str) {
if name != state.1 {
<(&'a str, &'a str) as IntoStyle>::reset(state);
}
let (style, _prev_name, prev_value) = state;
let (style, prev_name, prev_value) = state;
if value != *prev_value {
Rndr::set_css_property(style, name, value);
}
*prev_name = name;
*prev_value = value;
}

Expand Down Expand Up @@ -575,10 +577,11 @@ impl<'a> IntoStyle for (&'a str, String) {
if name != state.1 {
<(&'a str, String) as IntoStyle>::reset(state);
}
let (style, _prev_name, prev_value) = state;
let (style, prev_name, prev_value) = state;
if value != *prev_value {
Rndr::set_css_property(style, name, &value);
}
*prev_name = name;
*prev_value = value;
}

Expand Down
5 changes: 3 additions & 2 deletions tachys/src/reactive_graph/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ where

fn rebuild(self, state: &mut Self::State) {
let (name, mut f) = self;
let prev_value = state.effect.take_value();
// Name might've updated:
state.name = name;
state.effect = RenderEffect::new_with_value(
move |prev| {
let value = f.invoke().into();
Expand All @@ -120,7 +121,7 @@ where
unreachable!()
}
},
prev_value,
state.effect.take_value(),
);
}

Expand Down

0 comments on commit 0825c8f

Please sign in to comment.