pub struct Element<T: Render> {
pub is_fragment: bool,
pub tag: String,
pub attributes: BTreeMap<String, AttributeValue>,
pub children: Option<T>,
pub reff: Option<(String, String)>,
pub onclick: Arc<Mutex<Option<OnClickClosure>>>,
}Expand description
A single HTML element node carrying its tag, attributes, optional children and an optional click handler, used to build and render the DOM tree.
Fields§
§is_fragment: boolWhen true, the element renders only its children without wrapping tags.
tag: StringThe element’s tag name (e.g. div, flow-select).
attributes: BTreeMap<String, AttributeValue>The element’s attributes keyed by name.
children: Option<T>The element’s child content, if any.
reff: Option<(String, String)>Optional @name binding as a (name, value) pair recorded in the hooks map.
onclick: Arc<Mutex<Option<OnClickClosure>>>Retained click-event closure shared across clones of this element.
Implementations§
Source§impl<T: Render + Clone + 'static> Element<T>
impl<T: Render + Clone + 'static> Element<T>
Sourcepub fn on(self, name: &str, cb: Box<dyn Fn(MouseEvent, WebElement)>) -> Self
pub fn on(self, name: &str, cb: Box<dyn Fn(MouseEvent, WebElement)>) -> Self
Registers an event callback on this element. Currently only the
"click" event is wired up, attaching cb as a retained closure that
receives the mouse event and the target WebElement.
Trait Implementations§
Source§impl<T: Render + Clone + 'static> Render for Element<T>
impl<T: Render + Clone + 'static> Render for Element<T>
Source§fn render_node(
self,
parent: &mut WebElement,
map: &mut Hooks,
renderables: &mut Renderables,
) -> ElementResult<()>
fn render_node( self, parent: &mut WebElement, map: &mut Hooks, renderables: &mut Renderables, ) -> ElementResult<()>
Builds the live DOM nodes for this value under
_parent, recording any
@name hooks into _map and pushing retained renderables onto
_renderables. The default implementation does nothing.Source§fn render(&self, w: &mut Vec<String>) -> ElementResult<()>
fn render(&self, w: &mut Vec<String>) -> ElementResult<()>
Renders this value as HTML markup, appending fragments to
_w.Source§fn remove_event_listeners(&self) -> ElementResult<()>
fn remove_event_listeners(&self) -> ElementResult<()>
Releases any retained event-listener closures held by this value and its
children. The default implementation does nothing.
Source§fn html(&self) -> String
fn html(&self) -> String
Renders this value to an HTML string by concatenating its markup fragments.
Source§fn render_tree(self) -> ElementResult<Html>where
Self: Sized,
fn render_tree(self) -> ElementResult<Html>where
Self: Sized,
Renders this value into a detached container and returns an
Html
holding the resulting root elements, hooks and retained renderables.Source§fn render_tree_into(
self,
parent: &mut Element,
renderables: &mut Renderables,
) -> ElementResult<BTreeMap<String, Element>>where
Self: Sized,
fn render_tree_into(
self,
parent: &mut Element,
renderables: &mut Renderables,
) -> ElementResult<BTreeMap<String, Element>>where
Self: Sized,
Renders this value’s DOM nodes into the existing
parent element,
collecting retained renderables and returning the resulting map of
@name hook bindings.Auto Trait Implementations§
impl<T> !Send for Element<T>
impl<T> !Sync for Element<T>
impl<T> Freeze for Element<T>where
T: Freeze,
impl<T> RefUnwindSafe for Element<T>where
T: RefUnwindSafe,
impl<T> Unpin for Element<T>where
T: Unpin,
impl<T> UnsafeUnpin for Element<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Element<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more