Real Elements and Nodes

You'll sometimes want to do something to the real DOM Node that gets created from your VirtualNode.

You can accomplish this with the SpecialAttributes.on_create_elem attribute function.

fn main() {
use virtual_node::wrap_closure;

let mut div: VirtualNode = html! {
    <span>This span should get replaced</span>

    .on_create_elem = Some((
        wrap_closure(move |elem: web_sys::Element| {
            elem.set_inner_html("Hello world");

let div: Element = div.create_dom_node().node.unchecked_into();

assert_eq!(div.inner_html(), "Hello world");