1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use super::Node; use wasm_bindgen::JsCast; use web_sys as dom; pub struct App { node: Node, } impl App { pub fn new(dom_node: dom::Node, node: impl Into<Node>) -> App { let mut node = node.into(); dom_node.unchecked_ref::<dom::Element>().set_inner_html(""); node.insert_before(&dom_node, None); App { node } } pub fn forget(self) { std::mem::forget(self) } } impl Drop for App { fn drop(&mut self) { self.node.remove(); } }