[][src]Struct plaster::virtual_dom::vtag::VTag

pub struct VTag<COMP: Component> {
    pub reference: Option<Element>,
    pub listeners: Vec<Box<dyn Listener<COMP>>>,
    pub attributes: HashMap<String, String>,
    pub childs: Vec<VNode<COMP>>,
    pub classes: HashSet<String>,
    pub value: Option<String>,
    pub kind: Option<String>,
    pub checked: bool,
    // some fields omitted
}

A type for a virtual Element representation.

Fields

reference: Option<Element>

A reference to the Element.

listeners: Vec<Box<dyn Listener<COMP>>>

List of attached listeners.

attributes: HashMap<String, String>

List of attributes.

childs: Vec<VNode<COMP>>

The list of children nodes. Which also could have own children.

classes: HashSet<String>

List of attached classes.

value: Option<String>

Contains a value of an HtmlInputElement.

kind: Option<String>

Contains kind value of an HtmlInputElement.

checked: bool

Represents checked attribute of input. It exists to override standard behavior of checked attribute, because in original HTML it sets defaultChecked value of HtmlInputElement, but for reactive frameworks it's more useful to control checked value of an HtmlInputElement.

Methods

impl<COMP: Component> VTag<COMP>[src]

pub fn new<S: Into<Cow<'static, str>>>(tag: S) -> Self[src]

Creates a new VTag instance with tag name (cannot be changed later in DOM).

pub fn tag(&self) -> &str[src]

Returns tag of an Element. In HTML tags are always uppercase.

pub fn add_child(&mut self, child: VNode<COMP>)[src]

Add VNode child.

pub fn add_class(&mut self, class: &str)[src]

Adds asingle class to this virtual node. Actually it will set by Element.classList.add call later.

pub fn set_classes(&mut self, classes: &str)[src]

Add classes to this virtual node. Actually it will set by Element.classList.add call later.

pub fn set_value<T: ToString>(&mut self, value: &T)[src]

Sets value for an HtmlInputElement.

pub fn set_kind<T: ToString>(&mut self, value: &T)[src]

Sets kind property of an HtmlInputElement. Same as set type attribute.

pub fn set_checked(&mut self, value: bool)[src]

Sets checked property of an HtmlInputElement. (Not a value of node's attribute).

pub fn add_attribute<T: ToString>(&mut self, name: &str, value: &T)[src]

Adds attribute to a virtual node. Not every attribute works when it set as attribute. We use workarounds for: class, type/kind, value and checked.

pub fn add_listener(&mut self, listener: Box<dyn Listener<COMP>>)[src]

Adds new listener to the node. It's boxed because we want to keep it in a single list. Lates Listener::attach called to attach actual listener to a DOM node.

Trait Implementations

impl<COMP: Component> VDiff for VTag<COMP>[src]

type Component = COMP

The component which this instance put into.

fn detach(&mut self, parent: &Node) -> Option<Node>[src]

Remove VTag from parent.

fn apply(
    &mut self,
    parent: &Node,
    precursor: Option<&Node>,
    ancestor: Option<VNode<Self::Component>>,
    env: &Scope<Self::Component>
) -> Option<Node>
[src]

Renders virtual tag over DOM Element, but it also compares this with an ancestor VTag to compute what to patch in the actual DOM nodes.

impl<COMP: Component> PartialEq<VTag<COMP>> for VTag<COMP>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<COMP: Component> From<VTag<COMP>> for VNode<COMP>[src]

impl<COMP: Component> Debug for VTag<COMP>[src]

Auto Trait Implementations

impl<COMP> Unpin for VTag<COMP> where
    COMP: Unpin

impl<COMP> !Send for VTag<COMP>

impl<COMP> !Sync for VTag<COMP>

impl<COMP> !UnwindSafe for VTag<COMP>

impl<COMP> !RefUnwindSafe for VTag<COMP>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]