XMLDocument

Struct XMLDocument 

Source
pub struct XMLDocument { /* private fields */ }
Expand description

The XMLDocument class. XMLDocument

Methods from Deref<Target = Document>§

Source

pub fn implementation(&self) -> DOMImplementation

Getter of the implementation attribute. Document.implementation

Source

pub fn url(&self) -> JsString

Getter of the URL attribute. Document.URL

Source

pub fn document_uri(&self) -> JsString

Getter of the documentURI attribute. Document.documentURI

Source

pub fn compat_mode(&self) -> JsString

Getter of the compatMode attribute. Document.compatMode

Source

pub fn character_set(&self) -> JsString

Getter of the characterSet attribute. Document.characterSet

Source

pub fn charset(&self) -> JsString

Getter of the charset attribute. Document.charset

Source

pub fn input_encoding(&self) -> JsString

Getter of the inputEncoding attribute. Document.inputEncoding

Source

pub fn content_type(&self) -> JsString

Getter of the contentType attribute. Document.contentType

Source

pub fn doctype(&self) -> DocumentType

Getter of the doctype attribute. Document.doctype

Source

pub fn document_element(&self) -> Element

Getter of the documentElement attribute. Document.documentElement

Source

pub fn root_element(&self) -> SVGSVGElement

Getter of the rootElement attribute. Document.rootElement

Source

pub fn named_flows(&self) -> NamedFlowMap

Getter of the namedFlows attribute. Document.namedFlows

Source

pub fn active_view_transition(&self) -> ViewTransition

Getter of the activeViewTransition attribute. Document.activeViewTransition

Source

pub fn scrolling_element(&self) -> Element

Getter of the scrollingElement attribute. Document.scrollingElement

Source

pub fn fullscreen_enabled(&self) -> bool

Getter of the fullscreenEnabled attribute. Document.fullscreenEnabled

Source

pub fn fullscreen(&self) -> bool

Getter of the fullscreen attribute. Document.fullscreen

Source

pub fn onfullscreenchange(&self) -> Any

Getter of the onfullscreenchange attribute. Document.onfullscreenchange

Source

pub fn set_onfullscreenchange(&mut self, value: &Any)

Setter of the onfullscreenchange attribute. Document.onfullscreenchange

Source

pub fn onfullscreenerror(&self) -> Any

Getter of the onfullscreenerror attribute. Document.onfullscreenerror

Source

pub fn set_onfullscreenerror(&mut self, value: &Any)

Setter of the onfullscreenerror attribute. Document.onfullscreenerror

Source

pub fn location(&self) -> Location

Getter of the location attribute. Document.location

Source

pub fn domain(&self) -> JsString

Getter of the domain attribute. Document.domain

Source

pub fn set_domain(&mut self, value: &JsString)

Setter of the domain attribute. Document.domain

Source

pub fn referrer(&self) -> JsString

Getter of the referrer attribute. Document.referrer

Source

pub fn cookie(&self) -> JsString

Getter of the cookie attribute. Document.cookie

Setter of the cookie attribute. Document.cookie

Source

pub fn last_modified(&self) -> JsString

Getter of the lastModified attribute. Document.lastModified

Source

pub fn ready_state(&self) -> DocumentReadyState

Getter of the readyState attribute. Document.readyState

Source

pub fn title(&self) -> JsString

Getter of the title attribute. Document.title

Source

pub fn set_title(&mut self, value: &JsString)

Setter of the title attribute. Document.title

Source

pub fn dir(&self) -> JsString

Getter of the dir attribute. Document.dir

Source

pub fn set_dir(&mut self, value: &JsString)

Setter of the dir attribute. Document.dir

Source

pub fn body(&self) -> HTMLElement

Getter of the body attribute. Document.body

Source

pub fn set_body(&mut self, value: &HTMLElement)

Setter of the body attribute. Document.body

Source

pub fn head(&self) -> HTMLHeadElement

Getter of the head attribute. Document.head

Source

pub fn images(&self) -> HTMLCollection

Getter of the images attribute. Document.images

Source

pub fn embeds(&self) -> HTMLCollection

Getter of the embeds attribute. Document.embeds

Source

pub fn plugins(&self) -> HTMLCollection

Getter of the plugins attribute. Document.plugins

Getter of the links attribute. Document.links

Source

pub fn forms(&self) -> HTMLCollection

Getter of the forms attribute. Document.forms

Source

pub fn scripts(&self) -> HTMLCollection

Getter of the scripts attribute. Document.scripts

Source

pub fn current_script(&self) -> Any

Getter of the currentScript attribute. Document.currentScript

Source

pub fn default_view(&self) -> Any

Getter of the defaultView attribute. Document.defaultView

Source

pub fn design_mode(&self) -> JsString

Getter of the designMode attribute. Document.designMode

Source

pub fn set_design_mode(&mut self, value: &JsString)

Setter of the designMode attribute. Document.designMode

Source

pub fn hidden(&self) -> bool

Getter of the hidden attribute. Document.hidden

Source

pub fn visibility_state(&self) -> DocumentVisibilityState

Getter of the visibilityState attribute. Document.visibilityState

Source

pub fn onreadystatechange(&self) -> Any

Getter of the onreadystatechange attribute. Document.onreadystatechange

Source

pub fn set_onreadystatechange(&mut self, value: &Any)

Setter of the onreadystatechange attribute. Document.onreadystatechange

Source

pub fn onvisibilitychange(&self) -> Any

Getter of the onvisibilitychange attribute. Document.onvisibilitychange

Source

pub fn set_onvisibilitychange(&mut self, value: &Any)

Setter of the onvisibilitychange attribute. Document.onvisibilitychange

Source

pub fn fg_color(&self) -> JsString

Getter of the fgColor attribute. Document.fgColor

Source

pub fn set_fg_color(&mut self, value: &JsString)

Setter of the fgColor attribute. Document.fgColor

Getter of the linkColor attribute. Document.linkColor

Setter of the linkColor attribute. Document.linkColor

Getter of the vlinkColor attribute. Document.vlinkColor

Setter of the vlinkColor attribute. Document.vlinkColor

Getter of the alinkColor attribute. Document.alinkColor

Setter of the alinkColor attribute. Document.alinkColor

Source

pub fn bg_color(&self) -> JsString

Getter of the bgColor attribute. Document.bgColor

Source

pub fn set_bg_color(&mut self, value: &JsString)

Setter of the bgColor attribute. Document.bgColor

Source

pub fn anchors(&self) -> HTMLCollection

Getter of the anchors attribute. Document.anchors

Source

pub fn applets(&self) -> HTMLCollection

Getter of the applets attribute. Document.applets

Source

pub fn all(&self) -> HTMLAllCollection

Getter of the all attribute. Document.all

Source

pub fn onfreeze(&self) -> Any

Getter of the onfreeze attribute. Document.onfreeze

Source

pub fn set_onfreeze(&mut self, value: &Any)

Setter of the onfreeze attribute. Document.onfreeze

Source

pub fn onresume(&self) -> Any

Getter of the onresume attribute. Document.onresume

Source

pub fn set_onresume(&mut self, value: &Any)

Setter of the onresume attribute. Document.onresume

Source

pub fn was_discarded(&self) -> bool

Getter of the wasDiscarded attribute. Document.wasDiscarded

Source

pub fn permissions_policy(&self) -> PermissionsPolicy

Getter of the permissionsPolicy attribute. Document.permissionsPolicy

Source

pub fn picture_in_picture_enabled(&self) -> bool

Getter of the pictureInPictureEnabled attribute. Document.pictureInPictureEnabled

Source

pub fn onpointerlockchange(&self) -> Any

Getter of the onpointerlockchange attribute. Document.onpointerlockchange

Source

pub fn set_onpointerlockchange(&mut self, value: &Any)

Setter of the onpointerlockchange attribute. Document.onpointerlockchange

Source

pub fn onpointerlockerror(&self) -> Any

Getter of the onpointerlockerror attribute. Document.onpointerlockerror

Source

pub fn set_onpointerlockerror(&mut self, value: &Any)

Setter of the onpointerlockerror attribute. Document.onpointerlockerror

Source

pub fn prerendering(&self) -> bool

Getter of the prerendering attribute. Document.prerendering

Source

pub fn onprerenderingchange(&self) -> Any

Getter of the onprerenderingchange attribute. Document.onprerenderingchange

Source

pub fn set_onprerenderingchange(&mut self, value: &Any)

Setter of the onprerenderingchange attribute. Document.onprerenderingchange

Source

pub fn fragment_directive(&self) -> FragmentDirective

Getter of the fragmentDirective attribute. Document.fragmentDirective

Source

pub fn timeline(&self) -> DocumentTimeline

Getter of the timeline attribute. Document.timeline

Source

pub fn fonts(&self) -> FontFaceSet

Getter of the fonts attribute. Document.fonts

Source

pub fn children(&self) -> HTMLCollection

Getter of the children attribute. Document.children

Source

pub fn first_element_child(&self) -> Element

Getter of the firstElementChild attribute. Document.firstElementChild

Source

pub fn last_element_child(&self) -> Element

Getter of the lastElementChild attribute. Document.lastElementChild

Source

pub fn child_element_count(&self) -> u32

Getter of the childElementCount attribute. Document.childElementCount

Source

pub fn onbeforexrselect(&self) -> Any

Getter of the onbeforexrselect attribute. Document.onbeforexrselect

Source

pub fn set_onbeforexrselect(&mut self, value: &Any)

Setter of the onbeforexrselect attribute. Document.onbeforexrselect

Source

pub fn get_elements_by_tag_name( &self, qualified_name: &JsString, ) -> HTMLCollection

The getElementsByTagName method. Document.getElementsByTagName

Examples found in repository?
examples/button.rs (line 7)
4fn main() {
5    let con = Console::get();
6    let document = window().document();
7    let bodies = document.get_elements_by_tag_name(&"body".into());
8    if bodies.length() == 0 {
9        con.log(&["I Ain't got Nobody!".into()]);
10        return;
11    }
12    let body = bodies.item(0);
13    let mut button = document
14        .create_element(&"BUTTON".into())
15        .dyn_into::<HTMLButtonElement>()
16        .unwrap();
17
18    let style = button.style();
19    style.set_property(&"color".into(), &"red".into());
20    style.set_property(&"background-color".into(), &"#aaf".into());
21    style.set_property(&"border".into(), &"solid".into());
22
23    button.set_text_content(&"Click me".into());
24    button.add_event_listener(
25        &"click".into(),
26        &EventListener::from_closure(move |e: Event| {
27            let p = e.dyn_into::<PointerEvent>().unwrap();
28            con.log(&[p.client_x().into()]);
29            Undefined::VALUE
30        }),
31    );
32    body.append_child(button.dyn_ref::<Node>().unwrap());
33}
More examples
Hide additional examples
examples/audio.rs (line 15)
4fn main() {
5    let context = AudioContext::new();
6    println!("Got an AudioContext");
7
8    // Create oscillator
9    let mut oscillator = context.create_oscillator();
10    println!("Configuring oscillator");
11    oscillator.set_type_(&OscillatorType::TRIANGLE);
12    oscillator.frequency().set_value(261.63); // Middle C
13
14    let document = window().document();
15    let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16    let mut button = document
17        .create_element(&"BUTTON".into())
18        .dyn_into::<HTMLButtonElement>()
19        .unwrap();
20
21    button.set_text_content(&"Click me".into());
22    button.add_event_listener(
23        &JsString::from("click"),
24        &EventListener::from_closure(move |_e: Event| {
25            println!("Playing");
26            oscillator.connect_with_destination_param(
27                context.destination().unchecked_ref::<AudioParam>(),
28            );
29            oscillator.start_with_when(0.0);
30            println!("All done!");
31            Undefined::VALUE
32        }),
33    );
34    body.append_child(button.dyn_ref::<Node>().unwrap());
35}
Source

pub fn get_elements_by_tag_name_ns( &self, namespace: &JsString, local_name: &JsString, ) -> HTMLCollection

The getElementsByTagNameNS method. Document.getElementsByTagNameNS

Source

pub fn get_elements_by_class_name( &self, class_names: &JsString, ) -> HTMLCollection

The getElementsByClassName method. Document.getElementsByClassName

Source

pub fn create_element(&self, local_name: &JsString) -> Element

The createElement method. Document.createElement

Examples found in repository?
examples/button.rs (line 14)
4fn main() {
5    let con = Console::get();
6    let document = window().document();
7    let bodies = document.get_elements_by_tag_name(&"body".into());
8    if bodies.length() == 0 {
9        con.log(&["I Ain't got Nobody!".into()]);
10        return;
11    }
12    let body = bodies.item(0);
13    let mut button = document
14        .create_element(&"BUTTON".into())
15        .dyn_into::<HTMLButtonElement>()
16        .unwrap();
17
18    let style = button.style();
19    style.set_property(&"color".into(), &"red".into());
20    style.set_property(&"background-color".into(), &"#aaf".into());
21    style.set_property(&"border".into(), &"solid".into());
22
23    button.set_text_content(&"Click me".into());
24    button.add_event_listener(
25        &"click".into(),
26        &EventListener::from_closure(move |e: Event| {
27            let p = e.dyn_into::<PointerEvent>().unwrap();
28            con.log(&[p.client_x().into()]);
29            Undefined::VALUE
30        }),
31    );
32    body.append_child(button.dyn_ref::<Node>().unwrap());
33}
More examples
Hide additional examples
examples/audio.rs (line 17)
4fn main() {
5    let context = AudioContext::new();
6    println!("Got an AudioContext");
7
8    // Create oscillator
9    let mut oscillator = context.create_oscillator();
10    println!("Configuring oscillator");
11    oscillator.set_type_(&OscillatorType::TRIANGLE);
12    oscillator.frequency().set_value(261.63); // Middle C
13
14    let document = window().document();
15    let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16    let mut button = document
17        .create_element(&"BUTTON".into())
18        .dyn_into::<HTMLButtonElement>()
19        .unwrap();
20
21    button.set_text_content(&"Click me".into());
22    button.add_event_listener(
23        &JsString::from("click"),
24        &EventListener::from_closure(move |_e: Event| {
25            println!("Playing");
26            oscillator.connect_with_destination_param(
27                context.destination().unchecked_ref::<AudioParam>(),
28            );
29            oscillator.start_with_when(0.0);
30            println!("All done!");
31            Undefined::VALUE
32        }),
33    );
34    body.append_child(button.dyn_ref::<Node>().unwrap());
35}
Source

pub fn create_element_with_options( &self, local_name: &JsString, options: &Any, ) -> Element

The createElement method. Document.createElement

Source

pub fn create_element_ns( &self, namespace: &JsString, qualified_name: &JsString, ) -> Element

The createElementNS method. Document.createElementNS

Source

pub fn create_element_ns_with_options( &self, namespace: &JsString, qualified_name: &JsString, options: &Any, ) -> Element

The createElementNS method. Document.createElementNS

Source

pub fn create_document_fragment(&self) -> DocumentFragment

The createDocumentFragment method. Document.createDocumentFragment

Source

pub fn create_text_node(&self, data: &JsString) -> Text

The createTextNode method. Document.createTextNode

Source

pub fn create_cdata_section(&self, data: &JsString) -> CDATASection

The createCDATASection method. Document.createCDATASection

Source

pub fn create_comment(&self, data: &JsString) -> Comment

The createComment method. Document.createComment

Source

pub fn create_processing_instruction( &self, target: &JsString, data: &JsString, ) -> ProcessingInstruction

The createProcessingInstruction method. Document.createProcessingInstruction

Source

pub fn import_node(&self, node: &Node) -> Node

The importNode method. Document.importNode

Source

pub fn import_node_with_options(&self, node: &Node, options: &Any) -> Node

The importNode method. Document.importNode

Source

pub fn adopt_node(&self, node: &Node) -> Node

The adoptNode method. Document.adoptNode

Source

pub fn create_attribute(&self, local_name: &JsString) -> Attr

The createAttribute method. Document.createAttribute

Source

pub fn create_attribute_ns( &self, namespace: &JsString, qualified_name: &JsString, ) -> Attr

The createAttributeNS method. Document.createAttributeNS

Source

pub fn create_event(&self, interface: &JsString) -> Event

The createEvent method. Document.createEvent

Source

pub fn create_range(&self) -> Range

The createRange method. Document.createRange

Source

pub fn create_node_iterator(&self, root: &Node) -> NodeIterator

The createNodeIterator method. Document.createNodeIterator

Source

pub fn create_node_iterator_with_what_to_show( &self, root: &Node, what_to_show: u32, ) -> NodeIterator

The createNodeIterator method. Document.createNodeIterator

Source

pub fn create_node_iterator_with_what_to_show_and_filter( &self, root: &Node, what_to_show: u32, filter: &NodeFilter, ) -> NodeIterator

The createNodeIterator method. Document.createNodeIterator

Source

pub fn create_tree_walker(&self, root: &Node) -> TreeWalker

The createTreeWalker method. Document.createTreeWalker

Source

pub fn create_tree_walker_with_what_to_show( &self, root: &Node, what_to_show: u32, ) -> TreeWalker

The createTreeWalker method. Document.createTreeWalker

Source

pub fn create_tree_walker_with_what_to_show_and_filter( &self, root: &Node, what_to_show: u32, filter: &NodeFilter, ) -> TreeWalker

The createTreeWalker method. Document.createTreeWalker

Source

pub fn start_view_transition(&self) -> ViewTransition

The startViewTransition method. Document.startViewTransition

Source

pub fn start_view_transition_with_callback_options( &self, callback_options: &Any, ) -> ViewTransition

The startViewTransition method. Document.startViewTransition

Source

pub fn element_from_point(&self, x: f64, y: f64) -> Element

The elementFromPoint method. Document.elementFromPoint

Source

pub fn elements_from_point(&self, x: f64, y: f64) -> TypedArray<Element>

The elementsFromPoint method. Document.elementsFromPoint

Source

pub fn caret_position_from_point(&self, x: f64, y: f64) -> CaretPosition

The caretPositionFromPoint method. Document.caretPositionFromPoint

Source

pub fn caret_position_from_point_with_options( &self, x: f64, y: f64, options: &CaretPositionFromPointOptions, ) -> CaretPosition

The caretPositionFromPoint method. Document.caretPositionFromPoint

Source

pub fn measure_element(&self, element: &Element) -> FontMetrics

The measureElement method. Document.measureElement

Source

pub fn measure_text( &self, text: &JsString, style_map: &StylePropertyMapReadOnly, ) -> FontMetrics

The measureText method. Document.measureText

Source

pub fn exit_fullscreen(&self) -> Promise<Undefined>

The exitFullscreen method. Document.exitFullscreen

Source

pub fn get_elements_by_name(&self, element_name: &JsString) -> NodeList

The getElementsByName method. Document.getElementsByName

Source

pub fn open(&self) -> Document

The open method. Document.open

Source

pub fn open_with_unused1(&self, unused1: &JsString) -> Document

The open method. Document.open

Source

pub fn open_with_unused1_and_unused2( &self, unused1: &JsString, unused2: &JsString, ) -> Document

The open method. Document.open

Source

pub fn open_with_url_and_name_and_features( &self, url: &JsString, name: &JsString, features: &JsString, ) -> Any

The open method. Document.open

Source

pub fn close(&self) -> Undefined

The close method. Document.close

Source

pub fn write(&self, text: &Any) -> Undefined

The write method. Document.write

Source

pub fn writeln(&self, text: &Any) -> Undefined

The writeln method. Document.writeln

Source

pub fn has_focus(&self) -> bool

The hasFocus method. Document.hasFocus

Source

pub fn exec_command(&self, command_id: &JsString) -> bool

The execCommand method. Document.execCommand

Source

pub fn exec_command_with_show_ui( &self, command_id: &JsString, show_ui: bool, ) -> bool

The execCommand method. Document.execCommand

Source

pub fn exec_command_with_show_ui_and_value( &self, command_id: &JsString, show_ui: bool, value: &JsString, ) -> bool

The execCommand method. Document.execCommand

Source

pub fn query_command_enabled(&self, command_id: &JsString) -> bool

The queryCommandEnabled method. Document.queryCommandEnabled

Source

pub fn query_command_indeterm(&self, command_id: &JsString) -> bool

The queryCommandIndeterm method. Document.queryCommandIndeterm

Source

pub fn query_command_state(&self, command_id: &JsString) -> bool

The queryCommandState method. Document.queryCommandState

Source

pub fn query_command_supported(&self, command_id: &JsString) -> bool

The queryCommandSupported method. Document.queryCommandSupported

Source

pub fn query_command_value(&self, command_id: &JsString) -> JsString

The queryCommandValue method. Document.queryCommandValue

Source

pub fn clear(&self) -> Undefined

The clear method. Document.clear

Source

pub fn capture_events(&self) -> Undefined

The captureEvents method. Document.captureEvents

Source

pub fn release_events(&self) -> Undefined

The releaseEvents method. Document.releaseEvents

Source

pub fn exit_picture_in_picture(&self) -> Promise<Undefined>

The exitPictureInPicture method. Document.exitPictureInPicture

Source

pub fn exit_pointer_lock(&self) -> Undefined

The exitPointerLock method. Document.exitPointerLock

Source

pub fn request_storage_access_for( &self, requested_origin: &JsString, ) -> Promise<Undefined>

The requestStorageAccessFor method. Document.requestStorageAccessFor

The hasUnpartitionedCookieAccess method. Document.hasUnpartitionedCookieAccess

Source

pub fn get_selection(&self) -> Selection

The getSelection method. Document.getSelection

Source

pub fn has_storage_access(&self) -> Promise<bool>

The hasStorageAccess method. Document.hasStorageAccess

Source

pub fn request_storage_access(&self) -> Promise<Undefined>

The requestStorageAccess method. Document.requestStorageAccess

Source

pub fn has_private_token(&self, issuer: &JsString) -> Promise<bool>

The hasPrivateToken method. Document.hasPrivateToken

Source

pub fn has_redemption_record(&self, issuer: &JsString) -> Promise<bool>

The hasRedemptionRecord method. Document.hasRedemptionRecord

Source

pub fn get_box_quads(&self) -> TypedArray<DOMQuad>

The getBoxQuads method. Document.getBoxQuads

Source

pub fn get_box_quads_with_options( &self, options: &BoxQuadOptions, ) -> TypedArray<DOMQuad>

The getBoxQuads method. Document.getBoxQuads

Source

pub fn convert_quad_from_node(&self, quad: &DOMQuadInit, from: &Any) -> DOMQuad

The convertQuadFromNode method. Document.convertQuadFromNode

Source

pub fn convert_quad_from_node_with_options( &self, quad: &DOMQuadInit, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMQuad

The convertQuadFromNode method. Document.convertQuadFromNode

Source

pub fn convert_rect_from_node( &self, rect: &DOMRectReadOnly, from: &Any, ) -> DOMQuad

The convertRectFromNode method. Document.convertRectFromNode

Source

pub fn convert_rect_from_node_with_options( &self, rect: &DOMRectReadOnly, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMQuad

The convertRectFromNode method. Document.convertRectFromNode

Source

pub fn convert_point_from_node( &self, point: &DOMPointInit, from: &Any, ) -> DOMPoint

The convertPointFromNode method. Document.convertPointFromNode

Source

pub fn convert_point_from_node_with_options( &self, point: &DOMPointInit, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMPoint

The convertPointFromNode method. Document.convertPointFromNode

Source

pub fn get_element_by_id(&self, element_id: &JsString) -> Element

The getElementById method. Document.getElementById

Source

pub fn get_animations(&self) -> TypedArray<Animation>

The getAnimations method. Document.getAnimations

Source

pub fn prepend(&self, nodes: &Any) -> Undefined

The prepend method. Document.prepend

Source

pub fn append(&self, nodes: &Any) -> Undefined

The append method. Document.append

Source

pub fn replace_children(&self, nodes: &Any) -> Undefined

The replaceChildren method. Document.replaceChildren

Source

pub fn move_before(&self, node: &Node, child: &Node) -> Undefined

The moveBefore method. Document.moveBefore

Source

pub fn query_selector(&self, selectors: &JsString) -> Element

The querySelector method. Document.querySelector

Source

pub fn query_selector_all(&self, selectors: &JsString) -> NodeList

The querySelectorAll method. Document.querySelectorAll

Source

pub fn create_expression(&self, expression: &JsString) -> XPathExpression

The createExpression method. Document.createExpression

Source

pub fn create_expression_with_resolver( &self, expression: &JsString, resolver: &XPathNSResolver, ) -> XPathExpression

The createExpression method. Document.createExpression

Source

pub fn create_ns_resolver(&self, node_resolver: &Node) -> Node

The createNSResolver method. Document.createNSResolver

Source

pub fn evaluate( &self, expression: &JsString, context_node: &Node, ) -> XPathResult

The evaluate method. Document.evaluate

Source

pub fn evaluate_with_resolver( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, ) -> XPathResult

The evaluate method. Document.evaluate

Source

pub fn evaluate_with_resolver_and_type( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, type_: u16, ) -> XPathResult

The evaluate method. Document.evaluate

Source

pub fn evaluate_with_resolver_and_type_and_result( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, type_: u16, result: &XPathResult, ) -> XPathResult

The evaluate method. Document.evaluate

Methods from Deref<Target = Node>§

Source

pub fn node_type(&self) -> u16

Getter of the nodeType attribute. Node.nodeType

Source

pub fn node_name(&self) -> JsString

Getter of the nodeName attribute. Node.nodeName

Source

pub fn base_uri(&self) -> JsString

Getter of the baseURI attribute. Node.baseURI

Source

pub fn is_connected(&self) -> bool

Getter of the isConnected attribute. Node.isConnected

Source

pub fn owner_document(&self) -> Document

Getter of the ownerDocument attribute. Node.ownerDocument

Source

pub fn parent_node(&self) -> Node

Getter of the parentNode attribute. Node.parentNode

Source

pub fn parent_element(&self) -> Element

Getter of the parentElement attribute. Node.parentElement

Source

pub fn child_nodes(&self) -> NodeList

Getter of the childNodes attribute. Node.childNodes

Source

pub fn first_child(&self) -> Node

Getter of the firstChild attribute. Node.firstChild

Source

pub fn last_child(&self) -> Node

Getter of the lastChild attribute. Node.lastChild

Source

pub fn previous_sibling(&self) -> Node

Getter of the previousSibling attribute. Node.previousSibling

Source

pub fn next_sibling(&self) -> Node

Getter of the nextSibling attribute. Node.nextSibling

Source

pub fn node_value(&self) -> JsString

Getter of the nodeValue attribute. Node.nodeValue

Source

pub fn set_node_value(&mut self, value: &JsString)

Setter of the nodeValue attribute. Node.nodeValue

Source

pub fn text_content(&self) -> JsString

Getter of the textContent attribute. Node.textContent

Source

pub fn set_text_content(&mut self, value: &JsString)

Setter of the textContent attribute. Node.textContent

Examples found in repository?
examples/button.rs (line 23)
4fn main() {
5    let con = Console::get();
6    let document = window().document();
7    let bodies = document.get_elements_by_tag_name(&"body".into());
8    if bodies.length() == 0 {
9        con.log(&["I Ain't got Nobody!".into()]);
10        return;
11    }
12    let body = bodies.item(0);
13    let mut button = document
14        .create_element(&"BUTTON".into())
15        .dyn_into::<HTMLButtonElement>()
16        .unwrap();
17
18    let style = button.style();
19    style.set_property(&"color".into(), &"red".into());
20    style.set_property(&"background-color".into(), &"#aaf".into());
21    style.set_property(&"border".into(), &"solid".into());
22
23    button.set_text_content(&"Click me".into());
24    button.add_event_listener(
25        &"click".into(),
26        &EventListener::from_closure(move |e: Event| {
27            let p = e.dyn_into::<PointerEvent>().unwrap();
28            con.log(&[p.client_x().into()]);
29            Undefined::VALUE
30        }),
31    );
32    body.append_child(button.dyn_ref::<Node>().unwrap());
33}
More examples
Hide additional examples
examples/audio.rs (line 21)
4fn main() {
5    let context = AudioContext::new();
6    println!("Got an AudioContext");
7
8    // Create oscillator
9    let mut oscillator = context.create_oscillator();
10    println!("Configuring oscillator");
11    oscillator.set_type_(&OscillatorType::TRIANGLE);
12    oscillator.frequency().set_value(261.63); // Middle C
13
14    let document = window().document();
15    let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16    let mut button = document
17        .create_element(&"BUTTON".into())
18        .dyn_into::<HTMLButtonElement>()
19        .unwrap();
20
21    button.set_text_content(&"Click me".into());
22    button.add_event_listener(
23        &JsString::from("click"),
24        &EventListener::from_closure(move |_e: Event| {
25            println!("Playing");
26            oscillator.connect_with_destination_param(
27                context.destination().unchecked_ref::<AudioParam>(),
28            );
29            oscillator.start_with_when(0.0);
30            println!("All done!");
31            Undefined::VALUE
32        }),
33    );
34    body.append_child(button.dyn_ref::<Node>().unwrap());
35}
Source

pub fn get_root_node(&self) -> Node

The getRootNode method. Node.getRootNode

Source

pub fn get_root_node_with_options(&self, options: &GetRootNodeOptions) -> Node

The getRootNode method. Node.getRootNode

Source

pub fn has_child_nodes(&self) -> bool

The hasChildNodes method. Node.hasChildNodes

Source

pub fn normalize(&self) -> Undefined

The normalize method. Node.normalize

Source

pub fn clone_node(&self) -> Node

The cloneNode method. Node.cloneNode

Source

pub fn clone_node_with_subtree(&self, subtree: bool) -> Node

The cloneNode method. Node.cloneNode

Source

pub fn is_equal_node(&self, other_node: &Node) -> bool

The isEqualNode method. Node.isEqualNode

Source

pub fn is_same_node(&self, other_node: &Node) -> bool

The isSameNode method. Node.isSameNode

Source

pub fn compare_document_position(&self, other: &Node) -> u16

The compareDocumentPosition method. Node.compareDocumentPosition

Source

pub fn contains(&self, other: &Node) -> bool

The contains method. Node.contains

Source

pub fn lookup_prefix(&self, namespace: &JsString) -> JsString

The lookupPrefix method. Node.lookupPrefix

Source

pub fn lookup_namespace_uri(&self, prefix: &JsString) -> JsString

The lookupNamespaceURI method. Node.lookupNamespaceURI

Source

pub fn is_default_namespace(&self, namespace: &JsString) -> bool

The isDefaultNamespace method. Node.isDefaultNamespace

Source

pub fn insert_before(&self, node: &Node, child: &Node) -> Node

The insertBefore method. Node.insertBefore

Source

pub fn append_child(&self, node: &Node) -> Node

The appendChild method. Node.appendChild

Examples found in repository?
examples/button.rs (line 32)
4fn main() {
5    let con = Console::get();
6    let document = window().document();
7    let bodies = document.get_elements_by_tag_name(&"body".into());
8    if bodies.length() == 0 {
9        con.log(&["I Ain't got Nobody!".into()]);
10        return;
11    }
12    let body = bodies.item(0);
13    let mut button = document
14        .create_element(&"BUTTON".into())
15        .dyn_into::<HTMLButtonElement>()
16        .unwrap();
17
18    let style = button.style();
19    style.set_property(&"color".into(), &"red".into());
20    style.set_property(&"background-color".into(), &"#aaf".into());
21    style.set_property(&"border".into(), &"solid".into());
22
23    button.set_text_content(&"Click me".into());
24    button.add_event_listener(
25        &"click".into(),
26        &EventListener::from_closure(move |e: Event| {
27            let p = e.dyn_into::<PointerEvent>().unwrap();
28            con.log(&[p.client_x().into()]);
29            Undefined::VALUE
30        }),
31    );
32    body.append_child(button.dyn_ref::<Node>().unwrap());
33}
More examples
Hide additional examples
examples/audio.rs (line 34)
4fn main() {
5    let context = AudioContext::new();
6    println!("Got an AudioContext");
7
8    // Create oscillator
9    let mut oscillator = context.create_oscillator();
10    println!("Configuring oscillator");
11    oscillator.set_type_(&OscillatorType::TRIANGLE);
12    oscillator.frequency().set_value(261.63); // Middle C
13
14    let document = window().document();
15    let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16    let mut button = document
17        .create_element(&"BUTTON".into())
18        .dyn_into::<HTMLButtonElement>()
19        .unwrap();
20
21    button.set_text_content(&"Click me".into());
22    button.add_event_listener(
23        &JsString::from("click"),
24        &EventListener::from_closure(move |_e: Event| {
25            println!("Playing");
26            oscillator.connect_with_destination_param(
27                context.destination().unchecked_ref::<AudioParam>(),
28            );
29            oscillator.start_with_when(0.0);
30            println!("All done!");
31            Undefined::VALUE
32        }),
33    );
34    body.append_child(button.dyn_ref::<Node>().unwrap());
35}
Source

pub fn replace_child(&self, node: &Node, child: &Node) -> Node

The replaceChild method. Node.replaceChild

Source

pub fn remove_child(&self, child: &Node) -> Node

The removeChild method. Node.removeChild

Methods from Deref<Target = EventTarget>§

Source

pub fn add_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined

The addEventListener method. EventTarget.addEventListener

Examples found in repository?
examples/button.rs (lines 24-31)
4fn main() {
5    let con = Console::get();
6    let document = window().document();
7    let bodies = document.get_elements_by_tag_name(&"body".into());
8    if bodies.length() == 0 {
9        con.log(&["I Ain't got Nobody!".into()]);
10        return;
11    }
12    let body = bodies.item(0);
13    let mut button = document
14        .create_element(&"BUTTON".into())
15        .dyn_into::<HTMLButtonElement>()
16        .unwrap();
17
18    let style = button.style();
19    style.set_property(&"color".into(), &"red".into());
20    style.set_property(&"background-color".into(), &"#aaf".into());
21    style.set_property(&"border".into(), &"solid".into());
22
23    button.set_text_content(&"Click me".into());
24    button.add_event_listener(
25        &"click".into(),
26        &EventListener::from_closure(move |e: Event| {
27            let p = e.dyn_into::<PointerEvent>().unwrap();
28            con.log(&[p.client_x().into()]);
29            Undefined::VALUE
30        }),
31    );
32    body.append_child(button.dyn_ref::<Node>().unwrap());
33}
More examples
Hide additional examples
examples/audio.rs (lines 22-33)
4fn main() {
5    let context = AudioContext::new();
6    println!("Got an AudioContext");
7
8    // Create oscillator
9    let mut oscillator = context.create_oscillator();
10    println!("Configuring oscillator");
11    oscillator.set_type_(&OscillatorType::TRIANGLE);
12    oscillator.frequency().set_value(261.63); // Middle C
13
14    let document = window().document();
15    let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16    let mut button = document
17        .create_element(&"BUTTON".into())
18        .dyn_into::<HTMLButtonElement>()
19        .unwrap();
20
21    button.set_text_content(&"Click me".into());
22    button.add_event_listener(
23        &JsString::from("click"),
24        &EventListener::from_closure(move |_e: Event| {
25            println!("Playing");
26            oscillator.connect_with_destination_param(
27                context.destination().unchecked_ref::<AudioParam>(),
28            );
29            oscillator.start_with_when(0.0);
30            println!("All done!");
31            Undefined::VALUE
32        }),
33    );
34    body.append_child(button.dyn_ref::<Node>().unwrap());
35}
Source

pub fn add_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined

The addEventListener method. EventTarget.addEventListener

Source

pub fn remove_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined

The removeEventListener method. EventTarget.removeEventListener

Source

pub fn remove_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined

The removeEventListener method. EventTarget.removeEventListener

Source

pub fn dispatch_event(&self, event: &Event) -> bool

The dispatchEvent method. EventTarget.dispatchEvent

Source

pub fn when(&self, type_: &JsString) -> Observable

The when method. EventTarget.when

Source

pub fn when_with_options( &self, type_: &JsString, options: &ObservableEventListenerOptions, ) -> Observable

The when method. EventTarget.when

Methods from Deref<Target = Any>§

Source

pub fn get<T>(&self, prop: T) -> Val
where T: Into<Val>,

Gets the property prop

Source

pub fn set<K, V>(&self, prop: K, val: V)
where K: Into<Val>, V: Into<Val>,

Set the underlying js object property prop to val

Source

pub fn has<T>(&self, prop: T) -> bool
where T: Into<Val>,

Checks whether a property prop exists

Source

pub fn has_own_property(&self, prop: &str) -> bool

Checks whether a non-inherited property prop exists

Source

pub fn type_of(&self) -> String

Gets the typeof the underlying js object

Source

pub fn at<T>(&self, idx: T) -> Val
where T: Into<Val>,

Gets the element at index idx. Assumes the underlying js type is indexable

Source

pub fn to_vec<V>(&self) -> Vec<V>
where V: FromVal,

Converts the underlying js array to a Vec of V

Source

pub fn call(&self, f: &str, args: &[Val]) -> Val

Calls the method f with args, can return an undefined js value

Source

pub fn new(&self, args: &[Val]) -> Val

Calls the object’s constructor with args constructing a new object

Source

pub fn invoke(&self, args: &[Val]) -> Val

Invokes the function object with args, can return an undefined js value

Source

pub fn await_(&self) -> Val

Awaits the invoked function object

Source

pub fn instanceof(&self, v: Val) -> bool

Checks whether this Val is an instanceof v

Source

pub fn is_number(&self) -> bool

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn is_undefined(&self) -> bool

Source

pub fn is_error(&self) -> bool

Source

pub fn is_function(&self) -> bool

Source

pub fn as_<T>(&self) -> T
where T: FromVal,

Source

pub fn to_utf16(&self) -> Option<Vec<u16>>

Extracts UTF-16 data as Option<Vec>

Source

pub fn to_utf16_result(&self) -> Result<Vec<u16>, Val>

Extracts UTF-16 data, returning error if null or if self is error

Trait Implementations§

Source§

impl AsMut<Val> for XMLDocument

Source§

fn as_mut(&mut self) -> &mut Any

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Val> for XMLDocument

Source§

fn as_ref(&self) -> &Any

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for XMLDocument

Source§

fn clone(&self) -> XMLDocument

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XMLDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for XMLDocument

Source§

type Target = Document

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for XMLDocument

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl DynCast for XMLDocument

Source§

fn instanceof(val: &Any) -> bool

Implementation of val instanceof ThisType.
Source§

fn unchecked_from_val(v: Any) -> Self

Zero-cost unchecked conversion from Val into Self.
Source§

fn unchecked_from_val_ref(v: &Any) -> &Self

Zero-cost unchecked conversion from &Val into &Self.
Source§

fn unchecked_from_val_mut(v: &mut Any) -> &mut Self

Zero-cost unchecked conversion from &mut Val into &mut Self.
Source§

fn has_type<T>(&self) -> bool
where T: DynCast,

Source§

fn dyn_into<T>(self) -> Result<T, Self>
where T: DynCast,

Source§

fn dyn_ref<T>(&self) -> Option<&T>
where T: DynCast,

Source§

fn dyn_mut<T>(&mut self) -> Option<&mut T>
where T: DynCast,

Source§

fn unchecked_into<T>(self) -> T
where T: DynCast,

Source§

fn unchecked_ref<T>(&self) -> &T
where T: DynCast,

Source§

fn unchecked_mut<T>(&mut self) -> &mut T
where T: DynCast,

Source§

fn is_instance_of<T>(&self) -> bool
where T: DynCast,

Source§

fn is_type_of(val: &Val) -> bool

Customisable brand check – defaults to instanceof.
Source§

impl From<&XMLDocument> for Any

Source§

fn from(s: &XMLDocument) -> Any

Converts to this type from the input type.
Source§

impl From<XMLDocument> for Any

Source§

fn from(s: XMLDocument) -> Any

Converts to this type from the input type.
Source§

impl FromVal for XMLDocument

Source§

fn from_val(v: &Any) -> Self

Creates a Val object from another
Source§

fn take_ownership(v: AnyHandle) -> Self

Takes the ownership of a handle
Source§

fn as_handle(&self) -> AnyHandle

Returns the raw js handle
Source§

impl PartialEq for XMLDocument

Source§

fn eq(&self, other: &XMLDocument) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for XMLDocument

Source§

fn partial_cmp(&self, other: &XMLDocument) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for XMLDocument

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.