I’ve done a bigger VirtualDOM refactor in this PR and one of the new features are element references.
Excerpt from PR’s description:
ElRef - users can use native DOM elements safely because
ElReg::get checks if the referenced element exists, is in the DOM now and has the right type. And users don’t have to use any error-prone selectors. See examples (
So I recommend to switch to
master (Seed 0.6.0 will be released soon so you’ll be prepared) and use those el. references instead of selectors. It’s also easy to choose the element type or cast it into another with
Seed’s changelog for the next version contains some breaking changes but I hope that the migration won’t be painful.
Also there is a helper for getting values from elements - get_value. And as you can see, it’s very cumbersome and dangerous to try get value from inputs.
However to answer the original question:
let my_input_as_InputElement = my_input_as_Element.dyn_into::<HtmlInputElement>().ok();
// Or you can use .dyn_ref if you don't want to consume the original element.