Fix optional callback props implementation (#5225)
* fix optional event handler diffing * add regression test
This commit is contained in:
1 parent
f77a9162f5
commit
8eb4322de2
2 files changed
+30
-1
No files matched your search
@@ -697,10 +697,14 @@ mod struct_info {
|
||||
let name = field.name;
|
||||
if optional {
|
||||
quote! {
|
||||
// If the event handler is None, we don't need to update it
|
||||
// If both event handler are Some, update them in place
|
||||
if let (Some(old_handler), Some(new_handler)) = (self.#name.as_mut(), new.#name.as_ref()) {
|
||||
old_handler.__point_to(new_handler);
|
||||
}
|
||||
// Otherwise just move the new handler into self
|
||||
else {
|
||||
self.#name = new.#name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
|
||||
Reference in new issue
Block a user