Skip to main content

orbital_base_components/overlay/
element_ref.rs

1use leptos::html::ElementType;
2use send_wrapper::SendWrapper;
3use std::ops::Deref;
4
5/// Any DOM element reference type for generic `NodeRef` attachment.
6#[derive(Debug, Clone)]
7pub struct AnyElement {
8    el: SendWrapper<web_sys::Element>,
9}
10
11impl ElementType for AnyElement {
12    type Output = web_sys::Element;
13
14    const TAG: &'static str = "";
15
16    const SELF_CLOSING: bool = false;
17
18    const ESCAPE_CHILDREN: bool = false;
19
20    const NAMESPACE: Option<&'static str> = None;
21
22    fn tag(&self) -> &str {
23        ""
24    }
25}
26
27impl Deref for AnyElement {
28    type Target = web_sys::Element;
29
30    fn deref(&self) -> &Self::Target {
31        &self.el
32    }
33}
34
35/// Any HTML element reference type for generic `NodeRef` attachment.
36#[derive(Debug, Clone)]
37pub struct AnyHtmlElement {
38    el: SendWrapper<web_sys::HtmlElement>,
39}
40
41impl ElementType for AnyHtmlElement {
42    type Output = web_sys::HtmlElement;
43
44    const TAG: &'static str = "";
45
46    const SELF_CLOSING: bool = false;
47
48    const ESCAPE_CHILDREN: bool = false;
49
50    const NAMESPACE: Option<&'static str> = None;
51
52    fn tag(&self) -> &str {
53        ""
54    }
55}
56
57impl Deref for AnyHtmlElement {
58    type Target = web_sys::HtmlElement;
59
60    fn deref(&self) -> &Self::Target {
61        &self.el
62    }
63}