pub struct Element<NS, TAG, LEAF, ATT, VAL> where
    NS: PartialEq + Clone + Debug,
    TAG: PartialEq + Debug,
    LEAF: PartialEq + Clone + Debug,
    ATT: PartialEq + Clone + Debug,
    VAL: PartialEq + Clone + Debug
{ pub namespace: Option<NS>, pub tag: TAG, pub attrs: Vec<Attribute<NS, ATT, VAL>>, pub children: Vec<Node<NS, TAG, LEAF, ATT, VAL>>, pub self_closing: bool, }
Expand description

Represents an element of the virtual node An element has a generic tag, this tag could be a static str tag, such as usage in html dom. Example of which are div, a, input, img, etc.

Tag is a generic type, which can represent a different DOM tree other than the html dom such as widgets in native platform such as gtk, example of which are Hpane, Vbox, Image,

An element can have an optional namespace, such in the case for html dom where namespace like HTML and SVG, which needs to specified in order to create the DOM element to work on the browser.

The namespace is also needed in attributes where namespace are necessary such as xlink:href where the namespace xlink is needed in order for the linked element in an svg image to work.

Fields

namespace: Option<NS>

namespace of this element, svg elements requires namespace to render correcly in the browser

tag: TAG

the element tag, such as div, a, button

attrs: Vec<Attribute<NS, ATT, VAL>>

attributes for this element

children: Vec<Node<NS, TAG, LEAF, ATT, VAL>>

children elements of this element

self_closing: bool

is the element has a self closing tag

Implementations

create a new instance of an element

add attributes to this element

add children virtual node to this element

returns a refernce to the children of this node

returns a mutable reference to the children of this node

Removes an child node from this element and returns it.

The removed child is replaced by the last child of the element’s children.

Panics

Panics if index is out of bounds in children

Swaps the 2 child node in this element

Arguments
  • a - The index of the first child node
  • b - The index of the second child node
Panics

Panics if both a and b are out of bounds

consume self and return the children

return a reference to the attribute of this element

consume self and return the attributes

return the namespace of this element

return the tag of this element

consume self and return the tag of this element

change the tag of this element

remove the attributes with this key

remove the existing values of this attribute and add the new values

merge to existing attributes if it exist

return all the attribute values which the name &ATT

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.