1
2
3
4
5
6
7
8
9
10
11
12
13
/// Support working with [`web_sys::HtmlInputElement`]
pub trait HtmlInputElement {
    /// Get the [`web_sys::HtmlFormElement`] of an input.
    fn form(&self) -> Option<web_sys::HtmlFormElement>;
}

#[cfg(feature = "yew")]
impl HtmlInputElement for yew::prelude::NodeRef {
    fn form(&self) -> Option<web_sys::HtmlFormElement> {
        self.cast::<web_sys::HtmlInputElement>()
            .and_then(|input| input.form())
    }
}