use {
crate::{
scope_any,
El,
ScopeValue,
},
gloo_utils::document,
std::cell::Cell,
wasm_bindgen::UnwrapThrowExt,
};
thread_local!{
static ROOT: Cell<ScopeValue> = Cell::new(scope_any(()));
}
pub fn set_root_replace(id: &str, el: El) {
document().get_element_by_id(id).unwrap().replace_with_with_node_1(&el.0.borrow().el).unwrap_throw();
ROOT.with(|r| r.set(scope_any(el)));
}
pub fn set_root(elements: Vec<El>) {
document()
.body()
.unwrap()
.replace_children_with_node(&elements.iter().map(|e| e.0.borrow().el.clone()).collect());
ROOT.with(|r| r.set(scope_any(elements)));
}
pub fn set_root_non_dom<T: 'static>(value: T) {
ROOT.with(|r| r.set(scope_any(value)));
}