Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type-erased trait and support for shared AnyNodeRef across nodes #14

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

geoffreygarrett
Copy link

@geoffreygarrett geoffreygarrett commented Jan 5, 2025

Replaces element-specific macro implementations with a unified blanket implementation for node references in Leptos 0.7. Enables type-safe node reference handling across element types through a single IntoAnyNodeRef trait implementation.

Adds custom Attribute implementation for AnyNodeRefAttr to enable safe node reference sharing across conditional rendering branches, addressing the discussion about node ref sharing panics (see Discord discussion).

@geoffreygarrett
Copy link
Author

To clarify, this implementation:

impl<E: ElementType> NodeRefContainer<E> for AnyNodeRef {
    fn load(self, el: &Element) {
        self.0.set(Some(SendWrapper::new(el.clone())));
    }
}

Replaces the previous use of macros.

@geoffreygarrett geoffreygarrett changed the title feat(any-node-ref): type-erased node references with unified element support Add type-erased NodeRef for shared element handling Jan 6, 2025
@geoffreygarrett geoffreygarrett changed the title Add type-erased NodeRef for shared element handling Add type-erased trait and support for shared AnyNodeRef across nodes Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant