pub struct SpecialAttributes {
    pub dangerous_inner_html: Option<String>,
    /* private fields */
}
Expand description

A specially supported attributes.

Fields§

§dangerous_inner_html: Option<String>

Allows setting the innerHTML of an element.

Danger

Be sure to escape all untrusted input to avoid cross site scripting attacks.

Implementations§

source§

impl SpecialAttributes

source

pub fn on_create_element_key(&self) -> Option<&Cow<'static, str>>

The key for the on create element function

source

pub fn set_on_create_element<Key, Func>(&mut self, key: Key, func: Func)where Key: Into<Cow<'static, str>>, Func: FnMut(Element) + 'static,

Set the [SpecialAttributes.on_create_element] function.

Key

The key is used when one virtual-node is being patched over another.

If the new node’s key is different from the old node’s key, the on create element function gets called.

If the keys are the same, the function does not get called.

Examples
use wasm_bindgen::JsValue;

let mut node = VirtualNode::element("div");

// A key can be any `Into<Cow<'static, str>>`.
let key = "some-key";

let on_create_elem = move |elem: web_sys::Element| {
    assert_eq!(elem.id(), "");
};

node
    .as_velement_mut()
    .unwrap()
    .special_attributes
    .set_on_create_element(key, on_create_elem);
source

pub fn maybe_call_on_create_element(&self, element: &Element)

If an on_create_element function was set, call it.

source§

impl SpecialAttributes

source

pub fn on_remove_element_key(&self) -> Option<&Cow<'static, str>>

The key for the on remove element function

source

pub fn set_on_remove_element<Key, Func>(&mut self, key: Key, func: Func)where Key: Into<Cow<'static, str>>, Func: FnMut(Element) + 'static,

Set the [SpecialAttributes.on_remove_element] function.

Key

The key is used when one virtual-node is being patched over another.

If the old node’s key is different from the new node’s key, the on remove element function gets called for the old element.

If the keys are the same, the function does not get called.

Examples
use wasm_bindgen::JsValue;

let mut node = VirtualNode::element("div");

// A key can be any `Into<Cow<'static, str>>`.
let key = "some-key";

let on_remove_elem = move |elem: web_sys::Element| {
    assert_eq!(elem.id(), "");
};

node
    .as_velement_mut()
    .unwrap()
    .special_attributes
    .set_on_remove_element(key, on_remove_elem);
source

pub fn maybe_call_on_remove_element(&self, element: &Element)

If an on_remove_element function was set, call it.

Trait Implementations§

source§

impl Default for SpecialAttributes

source§

fn default() -> SpecialAttributes

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

impl PartialEq<SpecialAttributes> for SpecialAttributes

source§

fn eq(&self, other: &SpecialAttributes) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for SpecialAttributes

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.