Skip to content

Conversation

geoffreygarrett
Copy link
Contributor

@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
Contributor 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
@DanielleHuisman DanielleHuisman merged commit f09042d into RustForWeb:main Feb 10, 2025
1 check passed
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.

2 participants