dominator-testing 0.1.0

Helpers for testing dominator UIs with wasm-bindgen-test
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use wasm_bindgen::JsCast;
use web_sys::HtmlElement;

pub fn as_casted_element<T: JsCast>(ele: &impl JsCast) -> &T {
    ele.dyn_ref::<T>()
        .expect("The provided element is not castable to the requested element type")
}

pub fn as_html_element<T: JsCast>(ele: &T) -> &HtmlElement {
    ele.dyn_ref::<HtmlElement>()
        .expect("The provided element is not castable to HtmlElement")
}