[−][src]Struct mt_dom::Element
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, EVENT, MSG>>
attributes for this element
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
children elements of this element
self_closing: bool
is the element has a self closing tag
Implementations
impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
pub fn new(
namespace: Option<NS>,
tag: TAG,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>,
self_closing: bool
) -> Self
[src]
namespace: Option<NS>,
tag: TAG,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>,
self_closing: bool
) -> Self
create a new instance of an element
pub fn add_attributes(
&mut self,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
[src]
&mut self,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
add attributes to this element
pub fn add_children(
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
)
[src]
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
)
add children virtual node to this element
pub fn get_children(&self) -> &[Node<NS, TAG, ATT, VAL, EVENT, MSG>]
[src]
returns a refernce to the children of this node
pub fn children_mut(&mut self) -> &mut [Node<NS, TAG, ATT, VAL, EVENT, MSG>]
[src]
returns a mutable reference to the children of this node
pub fn take_children(self) -> Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
[src]
consume self and return the children
pub fn get_attributes(&self) -> &[Attribute<NS, ATT, VAL, EVENT, MSG>]
[src]
return a reference to the attribute of this element
pub fn take_attributes(self) -> Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
[src]
consume self and return the attributes
pub fn namespace(&self) -> Option<&NS>
[src]
return the namespace of this element
pub fn tag(&self) -> &TAG
[src]
return the tag of this element
pub fn take_tag(self) -> TAG
[src]
consume self and return the tag of this element
pub fn set_tag(&mut self, tag: TAG)
[src]
change the tag of this element
impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: PartialEq,
[src]
ATT: PartialEq,
Note: using the #[derive(PartialEq)] needs EVENT and MSG to also be PartialEq.
The reason this is manually implemented is, so that EVENT and MSG doesn't need to be PartialEq as it is part of the Callback objects and are not compared
pub fn remove_attribute(&mut self, key: &ATT)
[src]
remove the attributes with this key
pub fn set_attributes(
&mut self,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
[src]
&mut self,
attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
remove the existing values of this attribute and add the new values
pub fn merge_attributes(
&mut self,
new_attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
[src]
&mut self,
new_attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
merge to existing attributes if it exist
pub fn get_attribute_value(&self, name: &ATT) -> Option<Vec<&VAL>>
[src]
return all the attribute values which the name &ATT
impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<NS, TAG, ATT, VAL, EVENT, MSG> where
EVENT: 'static,
MSG: 'static,
[src]
EVENT: 'static,
MSG: 'static,
pub fn map_callback<MSG2>(
self,
cb: Callback<MSG, MSG2>
) -> Element<NS, TAG, ATT, VAL, EVENT, MSG2> where
MSG2: 'static,
[src]
self,
cb: Callback<MSG, MSG2>
) -> Element<NS, TAG, ATT, VAL, EVENT, MSG2> where
MSG2: 'static,
map_callback the return of the callback from MSG to MSG2
Trait Implementations
impl<NS, TAG, ATT, VAL, EVENT, MSG> Clone for Element<NS, TAG, ATT, VAL, EVENT, MSG> where
NS: Clone,
TAG: Clone,
ATT: Clone,
VAL: Clone,
[src]
NS: Clone,
TAG: Clone,
ATT: Clone,
VAL: Clone,
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<NS, TAG, ATT, VAL, EVENT, MSG> Debug for Element<NS, TAG, ATT, VAL, EVENT, MSG> where
NS: Debug,
TAG: Debug,
ATT: Debug,
VAL: Debug,
[src]
NS: Debug,
TAG: Debug,
ATT: Debug,
VAL: Debug,
Note: using the #[derive(Debug)] needs EVENT and MSG to also be Debug
The reason this is manually implemented is, so that EVENT and MSG doesn't need to be Debug as it is part of the Callback objects and are not shown.
impl<NS: Default, TAG: Default, ATT: Default, VAL: Default, EVENT: Default, MSG: Default> Default for Element<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
impl<NS: PartialEq, TAG: PartialEq, ATT: PartialEq, VAL: PartialEq, EVENT: PartialEq, MSG: PartialEq> PartialEq<Element<NS, TAG, ATT, VAL, EVENT, MSG>> for Element<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
pub fn eq(&self, other: &Element<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
[src]
pub fn ne(&self, other: &Element<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
[src]
impl<NS, TAG, ATT, VAL, EVENT, MSG> StructuralPartialEq for Element<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
Auto Trait Implementations
impl<NS, TAG, ATT, VAL, EVENT, MSG> !RefUnwindSafe for Element<NS, TAG, ATT, VAL, EVENT, MSG>
impl<NS, TAG, ATT, VAL, EVENT, MSG> !Send for Element<NS, TAG, ATT, VAL, EVENT, MSG>
impl<NS, TAG, ATT, VAL, EVENT, MSG> !Sync for Element<NS, TAG, ATT, VAL, EVENT, MSG>
impl<NS, TAG, ATT, VAL, EVENT, MSG> Unpin for Element<NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: Unpin,
NS: Unpin,
TAG: Unpin,
VAL: Unpin,
ATT: Unpin,
NS: Unpin,
TAG: Unpin,
VAL: Unpin,
impl<NS, TAG, ATT, VAL, EVENT, MSG> !UnwindSafe for Element<NS, TAG, ATT, VAL, EVENT, MSG>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,