use wasm_bindgen::JsCast;
use web_sys::{Document, Element, Window};
pub fn window() -> Window {
web_sys::window().unwrap()
}
pub fn document() -> Document {
web_sys::window().unwrap().document().unwrap()
}
pub fn body() -> std::result::Result<Element, String> {
let b = document()
.query_selector("body")
.unwrap()
.ok_or_else(|| "Unable to get body element".to_string())?;
Ok(b)
}
pub fn location() -> Result<web_sys::Location, wasm_bindgen::JsValue> {
let location = js_sys::Reflect::get(&js_sys::global(), &"location".into())?;
location.dyn_into()
}