Fix spread props diffing (#2679)

* Fix spread props diffing

* Add a regression test for extends prop diffing
This commit is contained in:
Evan Almloff 2024-07-24 01:57:05 +02:00 committed by GitHub
parent 6148941825
commit ea3d88c1dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View file

@ -640,6 +640,7 @@ mod struct_info {
let regular_fields: Vec<_> = self let regular_fields: Vec<_> = self
.included_fields() .included_fields()
.chain(self.extend_fields())
.filter(|f| !looks_like_signal_type(f.ty) && !looks_like_callback_type(f.ty)) .filter(|f| !looks_like_signal_type(f.ty) && !looks_like_callback_type(f.ty))
.map(|f| { .map(|f| {
let name = f.name; let name = f.name;

View file

@ -134,3 +134,32 @@ fn TakesSignal(sig: ReadOnlySignal<usize>, number: usize) -> Element {
button { "{number}" } 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![]);
}