pub struct Range(/* private fields */);
Implementations§
Source§impl Range
impl Range
pub fn to_string(&self) -> JsString
pub fn get_client_rects(&self) -> DOMRectList
pub fn get_bounding_client_rect(&self) -> DOMRect
pub fn extract_contents(&self) -> DocumentFragment
pub fn detach(&self) -> JsNullish
pub fn delete_contents(&self) -> JsNullish
pub fn clone_range(&self) -> Range
pub fn clone_contents(&self) -> DocumentFragment
pub fn new(browser: &Browser) -> Range
pub fn surround_contents(&self, newParent: &Node) -> JsNullish
pub fn set_start_before(&self, node: &Node) -> JsNullish
pub fn set_start_after(&self, node: &Node) -> JsNullish
pub fn set_end_before(&self, node: &Node) -> JsNullish
pub fn set_end_after(&self, node: &Node) -> JsNullish
pub fn select_node_contents(&self, node: &Node) -> JsNullish
pub fn select_node(&self, node: &Node) -> JsNullish
pub fn intersects_node(&self, node: &Node) -> JsBoolean
pub fn insert_node(&self, node: &Node) -> JsNullish
pub fn create_contextual_fragment( &self, fragment: &dyn ToJs<JsString>, ) -> DocumentFragment
pub fn collapse(&self, toStart: &dyn ToJs<JsNullable<JsBoolean>>) -> JsNullish
pub fn set_start_method( &self, node: &Node, offset: &dyn ToJs<JsNumber>, ) -> JsNullish
pub fn set_end_method( &self, node: &Node, offset: &dyn ToJs<JsNumber>, ) -> JsNullish
pub fn is_point_in_range( &self, node: &Node, offset: &dyn ToJs<JsNumber>, ) -> JsBoolean
pub fn compare_point( &self, node: &Node, offset: &dyn ToJs<JsNumber>, ) -> JsNumber
pub fn compare_boundary_points( &self, how: &dyn ToJs<JsNumber>, sourceRange: &Range, ) -> JsNumber
pub fn get_end__to__start(&self) -> JsNumber
pub fn set_end__to__start(&self, value: &dyn ToJs<JsNumber>)
pub fn get_end__to__end(&self) -> JsNumber
pub fn set_end__to__end(&self, value: &dyn ToJs<JsNumber>)
pub fn get_start__to__end(&self) -> JsNumber
pub fn set_start__to__end(&self, value: &dyn ToJs<JsNumber>)
pub fn get_start__to__start(&self) -> JsNumber
pub fn set_start__to__start(&self, value: &dyn ToJs<JsNumber>)
pub fn get_common_ancestor_container(&self) -> Node
pub fn set_common_ancestor_container(&self, value: &Node)
pub fn get_prototype(browser: &Browser) -> Range
pub fn set_prototype(browser: &Browser, value: &Range)
Methods from Deref<Target = AbstractRange>§
pub fn get_start_offset(&self) -> JsNumber
pub fn set_start_offset(&self, value: &dyn ToJs<JsNumber>)
pub fn get_start_container(&self) -> Node
pub fn set_start_container(&self, value: &Node)
pub fn get_end_offset(&self) -> JsNumber
pub fn set_end_offset(&self, value: &dyn ToJs<JsNumber>)
pub fn get_end_container(&self) -> Node
pub fn set_end_container(&self, value: &Node)
pub fn get_collapsed(&self) -> JsBoolean
pub fn set_collapsed(&self, value: &dyn ToJs<JsBoolean>)
Methods from Deref<Target = JsObject>§
Sourcepub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
pub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
Get a field value of in this object.
WSDOM provides built-in getters so you should use that instead when possible.
Use js_get_field
only when needed
fn example(browser: Browser) {
// you can get `window["location"]["href"]` like this
let href: JsValue = wsdom::dom::location(&browser).js_get_field(&"href");
// but you should use built-in getters instead
let href: JsString = wsdom::dom::location(&browser).get_href();
}
Sourcepub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
pub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
Set a field value of in this object.
WSDOM provides built-in setters so you should use that instead when possible.
Use js_set_field
only when needed
fn example(browser: Browser) {
// you can set `window["location"]["href"]` like this
wsdom::dom::location(&browser).js_set_field(&"href", &"https://example.com/");
// but you should use built-in setters instead
wsdom::dom::location(&browser).set_href(&"https://example.com");
}
Sourcepub fn js_call_method<'a>(
&'a self,
method_name: &'a str,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_method<'a>( &'a self, method_name: &'a str, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call a method on this object.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
fn example(browser: &Browser) {
let console = wsdom::dom::console(browser);
// you can call console.log like this
console.js_call_method("log", [&"hello" as &_], false);
// but the better way is to use
wsdom::dom::console(&browser).log(&[&"Hello" as &_]);
}
Be aware that the first argument (method_name
) is NOT escaped.
Set last_arg_variadic
to true
if you want to “spread” the last argument as obj.method(arg1, arg2, ...arg3)
.
Sourcepub fn js_call_self<'a>(
&'a self,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_self<'a>( &'a self, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call this object: obj()
.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
Methods from Deref<Target = JsValue>§
pub fn browser(&self) -> &Browser
Sourcepub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
pub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
Retrive this value from the JS side to the Rust side. Returns Future whose output is a serde_json::Value.
§use wsdom::dom::Browser
§use wsdom::dom::HTMLInputElement;
async fn example(input: &HTMLInputElement) { let _val = input.get_value().retrieve_json().await; }