vertigo/dom/
dom_element_ref.rs

1use crate::{dom::dom_id::DomId, driver_module::api::DomAccess, ApiImport};
2
3/// A reference to [DomElement](crate::DomElement).
4///
5/// Use [DomElement::get_ref](crate::DomElement::get_ref) to obtain. See [js!](crate::js!) macro for an example.
6#[derive(Clone)]
7pub struct DomElementRef {
8    api: ApiImport,
9    id: DomId,
10}
11
12impl DomElementRef {
13    pub fn new(api: ApiImport, id: DomId) -> DomElementRef {
14        DomElementRef { api, id }
15    }
16
17    pub fn dom_access(&self) -> DomAccess {
18        self.api.dom_access().element(self.id)
19    }
20}
21
22impl PartialEq for DomElementRef {
23    fn eq(&self, other: &Self) -> bool {
24        self.id == other.id
25    }
26}