Skip to content

Commit

Permalink
fix IntoProperty not implemented for (Element, JsValue)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi739 committed Feb 11, 2025
1 parent 1218130 commit dc22b45
Showing 1 changed file with 2 additions and 65 deletions.
67 changes: 2 additions & 65 deletions tachys/src/reactive_graph/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,72 +494,9 @@ pub enum BoolOrT<T> {
T(T),
}

impl<T> IntoProperty for BoolOrT<T>
where
T: IntoProperty<State = (Element, JsValue)>
+ Into<JsValue>
+ Clone
+ 'static,
{
type State = (Element, JsValue);
type Cloneable = Self;
type CloneableOwned = Self;

fn hydrate<const FROM_SERVER: bool>(
self,
el: &Element,
key: &str,
) -> Self::State {
match self.clone() {
Self::T(s) => {
s.hydrate::<FROM_SERVER>(el, key);
}
Self::Bool(b) => {
<bool as IntoProperty>::hydrate::<FROM_SERVER>(b, el, key);
}
};

(el.clone(), self.into())
}

fn build(self, el: &Element, key: &str) -> Self::State {
match self.clone() {
Self::T(s) => {
s.build(el, key);
}
Self::Bool(b) => {
<bool as IntoProperty>::build(b, el, key);
}
}

(el.clone(), self.into())
}

fn rebuild(self, state: &mut Self::State, key: &str) {
let (el, prev) = state;

match self {
Self::T(s) => s.rebuild(&mut (el.clone(), prev.clone()), key),
Self::Bool(b) => <bool as IntoProperty>::rebuild(
b,
&mut (el.clone(), prev.clone()),
key,
),
}
}

fn into_cloneable(self) -> Self::Cloneable {
self
}

fn into_cloneable_owned(self) -> Self::CloneableOwned {
self
}
}

impl<T> IntoProperty for Option<BoolOrT<T>>
where
T: IntoProperty<State = Option<(Element, JsValue)>>
T: IntoProperty<State = (Element, JsValue)>
+ Into<JsValue>
+ Clone
+ 'static,
Expand Down Expand Up @@ -607,7 +544,7 @@ where
let (el, prev) = state;
match f {
BoolOrT::T(s) => {
s.rebuild(&mut Some((el.clone(), prev.clone())), key)
s.rebuild(&mut (el.clone(), prev.clone()), key)
}
BoolOrT::Bool(b) => <bool as IntoProperty>::rebuild(
b,
Expand Down

0 comments on commit dc22b45

Please sign in to comment.