Skip to main content

rust_fel/
element.rs

1use crate::props::Props;
2use std::fmt;
3
4/// The structure which represents a Virtual [DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction) for the ```rust_fel``` library.
5/// It holds [rust_fel::Props](../rust_fel/struct.Props.html) , which in turn hold a [Vec](https://doc.rust-lang.org/beta/std/vec/) of ```Element's``` as ```children```.
6/// This means ```Element``` can represent a tree of [DOM Elements](https://developer.mozilla.org/en-US/docs/Web/API/Element).
7#[derive(Default)]
8pub struct Element {
9    pub html_type: String,
10    pub props: Props,
11}
12
13impl fmt::Debug for Element {
14    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15        write!(
16            f,
17            "{:#?} this is a element html_type and here are it's props -> {:#?}",
18            self.html_type, self.props
19        )
20    }
21}
22
23impl Element {
24    pub fn new(html_type: String, props: Props) -> Element {
25        Element { html_type, props }
26    }
27}