Struct percy_dom::SpecialAttributes [−][src]
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
The key for the on create element function
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);
If an on_create_element
function was set, call it.
The key for the on remove element function
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);
If an on_remove_element
function was set, call it.
Trait Implementations
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 !=
.