mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 06:00:21 +00:00
Fix spread props diffing (#2679)
* Fix spread props diffing * Add a regression test for extends prop diffing
This commit is contained in:
parent
6148941825
commit
ea3d88c1dd
2 changed files with 30 additions and 0 deletions
|
@ -640,6 +640,7 @@ mod struct_info {
|
|||
|
||||
let regular_fields: Vec<_> = self
|
||||
.included_fields()
|
||||
.chain(self.extend_fields())
|
||||
.filter(|f| !looks_like_signal_type(f.ty) && !looks_like_callback_type(f.ty))
|
||||
.map(|f| {
|
||||
let name = f.name;
|
||||
|
|
|
@ -134,3 +134,32 @@ fn TakesSignal(sig: ReadOnlySignal<usize>, number: usize) -> Element {
|
|||
button { "{number}" }
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/DioxusLabs/dioxus/issues/2582
|
||||
#[test]
|
||||
fn spreads_memorize_in_place() {
|
||||
#[derive(Props, Clone, PartialEq)]
|
||||
struct CompProps {
|
||||
#[props(extends = GlobalAttributes)]
|
||||
attributes: Vec<Attribute>,
|
||||
}
|
||||
|
||||
let mut props = CompProps::builder().build();
|
||||
assert!(!props.memoize(&CompProps::builder().all("123").build()));
|
||||
assert_eq!(
|
||||
props.attributes,
|
||||
vec![Attribute::new("all", "123", Some("style"), false)]
|
||||
);
|
||||
|
||||
assert!(!props.memoize(&CompProps::builder().width("123").build()));
|
||||
assert_eq!(
|
||||
props.attributes,
|
||||
vec![Attribute::new("width", "123", Some("style"), false)]
|
||||
);
|
||||
|
||||
assert!(!props.memoize(&CompProps::builder().build()));
|
||||
assert_eq!(props.attributes, vec![]);
|
||||
|
||||
assert!(props.memoize(&CompProps::builder().build()));
|
||||
assert_eq!(props.attributes, vec![]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue