Skip to content

Make NodeRef generic to avoid manual casting #766

Description

@AMNRG

Currently NodeRef returns always a web_sys::Node. To improve type safety and code readability, we could make NodeRef generic, allowing it to be typed directly as e.g. web_sys::HtmlInputElement.

Current state:

let username_input = create_node_ref();
...
let username = username_input.get().dyn_into::<HtmlInputElement>().unwrap().value();

Desired state:

let username_input: NodeRef<HtmlInputElement> = create_node_ref();
...
let username = username_input.get().value();

It would be super convenient if the type could be determined directly from the view macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: new feature or improvement to existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions