Fix early drop of eventhandlers (#2126)

* fix early drop of eventhandlers

* add a test for stale props that are memorized in place

* fix clippy
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-03-22 14:37:02 -07:00
1 parent acbf7dfc4f
commit 0662033c84
7 files changed
+95 -15

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ pub(crate) type BoxedAnyProps = Box<dyn AnyProps>;
pub(crate) trait AnyProps: 'static {
/// Render the component with the internal props.
fn render(&self) -> RenderReturn;
/// Check if the props are the same as the type erased props of another component.
/// Make the old props equal to the new type erased props. Return if the props were equal and should be memoized.
fn memoize(&mut self, other: &dyn Any) -> bool;
/// Get the props as a type erased `dyn Any`.
fn props(&self) -> &dyn Any;
-3
View File
@@ -83,9 +83,6 @@ impl VNode {
return;
}
// First, move over the props from the old to the new, dropping old props in the process
dom.scopes[scope_id.0].props = new.props.duplicate();
// Now run the component and diff it
let new = dom.run_scope(scope_id);
dom.diff_scope(to, scope_id, new);
+1 -1
View File
@@ -31,7 +31,7 @@ pub trait Properties: Clone + Sized + 'static {
/// Create a builder for this component.
fn builder() -> Self::Builder;
/// Compare two props to see if they are memoizable.
/// Make the old props equal to the new props. Return if the props were equal and should be memoized.
fn memoize(&mut self, other: &Self) -> bool;
/// Create a component from the props.