pub fn set_siblings_inert(root_id: &str, inert: bool) {
#[cfg(target_arch = "wasm32")]
{
set_siblings_inert_wasm(root_id, inert);
}
#[cfg(not(target_arch = "wasm32"))]
{
let _ = root_id;
let _ = inert;
}
}
#[cfg(target_arch = "wasm32")]
fn set_siblings_inert_wasm(root_id: &str, inert: bool) {
use wasm_bindgen::JsCast;
let Some(window) = web_sys::window() else {
return;
};
let Some(document) = window.document() else {
return;
};
let Some(body) = document.body() else { return };
let body_el: &web_sys::Element = body.unchecked_ref();
let root_el = document.get_element_by_id(root_id);
let children = body_el.children();
let len = children.length();
for i in 0..len {
let Some(child) = children.item(i) else {
continue;
};
let skip = root_el.as_ref().is_some_and(|re| child.contains(Some(re)));
if skip {
continue;
}
if inert {
let _ = child.set_attribute("inert", "");
} else {
let _ = child.remove_attribute("inert");
}
}
}