pub struct CharacterData { /* private fields */ }Expand description
The CharacterData class.
CharacterData
Implementations§
Source§impl CharacterData
impl CharacterData
Sourcepub fn data(&self) -> JsString
pub fn data(&self) -> JsString
Getter of the data attribute.
CharacterData.data
Sourcepub fn set_data(&mut self, value: &JsString)
pub fn set_data(&mut self, value: &JsString)
Setter of the data attribute.
CharacterData.data
Source§impl CharacterData
impl CharacterData
Sourcepub fn length(&self) -> u32
pub fn length(&self) -> u32
Getter of the length attribute.
CharacterData.length
Source§impl CharacterData
impl CharacterData
Sourcepub fn previous_element_sibling(&self) -> Element
pub fn previous_element_sibling(&self) -> Element
Getter of the previousElementSibling attribute.
CharacterData.previousElementSibling
Source§impl CharacterData
impl CharacterData
Sourcepub fn next_element_sibling(&self) -> Element
pub fn next_element_sibling(&self) -> Element
Getter of the nextElementSibling attribute.
CharacterData.nextElementSibling
Source§impl CharacterData
impl CharacterData
Sourcepub fn substring_data(&self, offset: u32, count: u32) -> JsString
pub fn substring_data(&self, offset: u32, count: u32) -> JsString
The substringData method.
CharacterData.substringData
Source§impl CharacterData
impl CharacterData
Sourcepub fn append_data(&self, data: &JsString) -> Undefined
pub fn append_data(&self, data: &JsString) -> Undefined
The appendData method.
CharacterData.appendData
Source§impl CharacterData
impl CharacterData
Sourcepub fn insert_data(&self, offset: u32, data: &JsString) -> Undefined
pub fn insert_data(&self, offset: u32, data: &JsString) -> Undefined
The insertData method.
CharacterData.insertData
Source§impl CharacterData
impl CharacterData
Sourcepub fn delete_data(&self, offset: u32, count: u32) -> Undefined
pub fn delete_data(&self, offset: u32, count: u32) -> Undefined
The deleteData method.
CharacterData.deleteData
Source§impl CharacterData
impl CharacterData
Sourcepub fn replace_data(
&self,
offset: u32,
count: u32,
data: &JsString,
) -> Undefined
pub fn replace_data( &self, offset: u32, count: u32, data: &JsString, ) -> Undefined
The replaceData method.
CharacterData.replaceData
Source§impl CharacterData
impl CharacterData
Sourcepub fn before(&self, nodes: &Any) -> Undefined
pub fn before(&self, nodes: &Any) -> Undefined
The before method.
CharacterData.before
Source§impl CharacterData
impl CharacterData
Sourcepub fn after(&self, nodes: &Any) -> Undefined
pub fn after(&self, nodes: &Any) -> Undefined
The after method.
CharacterData.after
Source§impl CharacterData
impl CharacterData
Sourcepub fn replace_with(&self, nodes: &Any) -> Undefined
pub fn replace_with(&self, nodes: &Any) -> Undefined
The replaceWith method.
CharacterData.replaceWith
Source§impl CharacterData
impl CharacterData
Sourcepub fn remove(&self) -> Undefined
pub fn remove(&self) -> Undefined
The remove method.
CharacterData.remove
Methods from Deref<Target = Node>§
Sourcepub fn node_type(&self) -> u16
pub fn node_type(&self) -> u16
Getter of the nodeType attribute.
Node.nodeType
Sourcepub fn node_name(&self) -> JsString
pub fn node_name(&self) -> JsString
Getter of the nodeName attribute.
Node.nodeName
Sourcepub fn base_uri(&self) -> JsString
pub fn base_uri(&self) -> JsString
Getter of the baseURI attribute.
Node.baseURI
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Getter of the isConnected attribute.
Node.isConnected
Sourcepub fn owner_document(&self) -> Document
pub fn owner_document(&self) -> Document
Getter of the ownerDocument attribute.
Node.ownerDocument
Sourcepub fn parent_node(&self) -> Node
pub fn parent_node(&self) -> Node
Getter of the parentNode attribute.
Node.parentNode
Sourcepub fn parent_element(&self) -> Element
pub fn parent_element(&self) -> Element
Getter of the parentElement attribute.
Node.parentElement
Sourcepub fn child_nodes(&self) -> NodeList
pub fn child_nodes(&self) -> NodeList
Getter of the childNodes attribute.
Node.childNodes
Sourcepub fn first_child(&self) -> Node
pub fn first_child(&self) -> Node
Getter of the firstChild attribute.
Node.firstChild
Sourcepub fn last_child(&self) -> Node
pub fn last_child(&self) -> Node
Getter of the lastChild attribute.
Node.lastChild
Sourcepub fn previous_sibling(&self) -> Node
pub fn previous_sibling(&self) -> Node
Getter of the previousSibling attribute.
Node.previousSibling
Sourcepub fn next_sibling(&self) -> Node
pub fn next_sibling(&self) -> Node
Getter of the nextSibling attribute.
Node.nextSibling
Sourcepub fn node_value(&self) -> JsString
pub fn node_value(&self) -> JsString
Getter of the nodeValue attribute.
Node.nodeValue
Sourcepub fn set_node_value(&mut self, value: &JsString)
pub fn set_node_value(&mut self, value: &JsString)
Setter of the nodeValue attribute.
Node.nodeValue
Sourcepub fn text_content(&self) -> JsString
pub fn text_content(&self) -> JsString
Getter of the textContent attribute.
Node.textContent
Sourcepub fn set_text_content(&mut self, value: &JsString)
pub fn set_text_content(&mut self, value: &JsString)
Setter of the textContent attribute.
Node.textContent
Examples found in repository?
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
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}Sourcepub fn get_root_node(&self) -> Node
pub fn get_root_node(&self) -> Node
The getRootNode method.
Node.getRootNode
Sourcepub fn get_root_node_with_options(&self, options: &GetRootNodeOptions) -> Node
pub fn get_root_node_with_options(&self, options: &GetRootNodeOptions) -> Node
The getRootNode method.
Node.getRootNode
Sourcepub fn has_child_nodes(&self) -> bool
pub fn has_child_nodes(&self) -> bool
The hasChildNodes method.
Node.hasChildNodes
Sourcepub fn normalize(&self) -> Undefined
pub fn normalize(&self) -> Undefined
The normalize method.
Node.normalize
Sourcepub fn clone_node(&self) -> Node
pub fn clone_node(&self) -> Node
The cloneNode method.
Node.cloneNode
Sourcepub fn clone_node_with_subtree(&self, subtree: bool) -> Node
pub fn clone_node_with_subtree(&self, subtree: bool) -> Node
The cloneNode method.
Node.cloneNode
Sourcepub fn is_equal_node(&self, other_node: &Node) -> bool
pub fn is_equal_node(&self, other_node: &Node) -> bool
The isEqualNode method.
Node.isEqualNode
Sourcepub fn is_same_node(&self, other_node: &Node) -> bool
pub fn is_same_node(&self, other_node: &Node) -> bool
The isSameNode method.
Node.isSameNode
Sourcepub fn compare_document_position(&self, other: &Node) -> u16
pub fn compare_document_position(&self, other: &Node) -> u16
The compareDocumentPosition method.
Node.compareDocumentPosition
Sourcepub fn contains(&self, other: &Node) -> bool
pub fn contains(&self, other: &Node) -> bool
The contains method.
Node.contains
Sourcepub fn lookup_prefix(&self, namespace: &JsString) -> JsString
pub fn lookup_prefix(&self, namespace: &JsString) -> JsString
The lookupPrefix method.
Node.lookupPrefix
Sourcepub fn lookup_namespace_uri(&self, prefix: &JsString) -> JsString
pub fn lookup_namespace_uri(&self, prefix: &JsString) -> JsString
The lookupNamespaceURI method.
Node.lookupNamespaceURI
Sourcepub fn is_default_namespace(&self, namespace: &JsString) -> bool
pub fn is_default_namespace(&self, namespace: &JsString) -> bool
The isDefaultNamespace method.
Node.isDefaultNamespace
Sourcepub fn insert_before(&self, node: &Node, child: &Node) -> Node
pub fn insert_before(&self, node: &Node, child: &Node) -> Node
The insertBefore method.
Node.insertBefore
Sourcepub fn append_child(&self, node: &Node) -> Node
pub fn append_child(&self, node: &Node) -> Node
The appendChild method.
Node.appendChild
Examples found in repository?
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
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}Sourcepub fn replace_child(&self, node: &Node, child: &Node) -> Node
pub fn replace_child(&self, node: &Node, child: &Node) -> Node
The replaceChild method.
Node.replaceChild
Sourcepub fn remove_child(&self, child: &Node) -> Node
pub fn remove_child(&self, child: &Node) -> Node
The removeChild method.
Node.removeChild
Methods from Deref<Target = EventTarget>§
Sourcepub fn add_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn add_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Examples found in repository?
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
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}Sourcepub fn add_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn add_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Sourcepub fn remove_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn remove_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn remove_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn remove_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn dispatch_event(&self, event: &Event) -> bool
pub fn dispatch_event(&self, event: &Event) -> bool
The dispatchEvent method.
EventTarget.dispatchEvent
Sourcepub fn when(&self, type_: &JsString) -> Observable
pub fn when(&self, type_: &JsString) -> Observable
The when method.
EventTarget.when
Sourcepub fn when_with_options(
&self,
type_: &JsString,
options: &ObservableEventListenerOptions,
) -> Observable
pub fn when_with_options( &self, type_: &JsString, options: &ObservableEventListenerOptions, ) -> Observable
The when method.
EventTarget.when
Methods from Deref<Target = Any>§
Sourcepub fn has_own_property(&self, prop: &str) -> bool
pub fn has_own_property(&self, prop: &str) -> bool
Checks whether a non-inherited property prop exists
Sourcepub fn at<T>(&self, idx: T) -> Val
pub fn at<T>(&self, idx: T) -> Val
Gets the element at index idx. Assumes the underlying js type is indexable
Sourcepub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
pub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
Converts the underlying js array to a Vec of V
Sourcepub fn call(&self, f: &str, args: &[Val]) -> Val
pub fn call(&self, f: &str, args: &[Val]) -> Val
Calls the method f with args, can return an undefined js value
Sourcepub fn new(&self, args: &[Val]) -> Val
pub fn new(&self, args: &[Val]) -> Val
Calls the object’s constructor with args constructing a new object
Sourcepub fn invoke(&self, args: &[Val]) -> Val
pub fn invoke(&self, args: &[Val]) -> Val
Invokes the function object with args, can return an undefined js value
Sourcepub fn instanceof(&self, v: Val) -> bool
pub fn instanceof(&self, v: Val) -> bool
Checks whether this Val is an instanceof v
pub fn is_number(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_error(&self) -> bool
pub fn is_function(&self) -> bool
pub fn as_<T>(&self) -> Twhere
T: FromVal,
Trait Implementations§
Source§impl AsMut<Val> for CharacterData
impl AsMut<Val> for CharacterData
Source§impl AsRef<Val> for CharacterData
impl AsRef<Val> for CharacterData
Source§impl Clone for CharacterData
impl Clone for CharacterData
Source§fn clone(&self) -> CharacterData
fn clone(&self) -> CharacterData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CharacterData
impl Debug for CharacterData
Source§impl Deref for CharacterData
impl Deref for CharacterData
Source§impl DerefMut for CharacterData
impl DerefMut for CharacterData
Source§impl DynCast for CharacterData
impl DynCast for CharacterData
Source§fn instanceof(val: &Any) -> bool
fn instanceof(val: &Any) -> bool
val instanceof ThisType.Source§fn unchecked_from_val(v: Any) -> Self
fn unchecked_from_val(v: Any) -> Self
Val into Self.Source§fn unchecked_from_val_ref(v: &Any) -> &Self
fn unchecked_from_val_ref(v: &Any) -> &Self
&Val into &Self.Source§fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
&mut Val into &mut Self.fn has_type<T>(&self) -> boolwhere
T: DynCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: DynCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: DynCast,
fn dyn_mut<T>(&mut self) -> Option<&mut T>where
T: DynCast,
fn unchecked_into<T>(self) -> Twhere
T: DynCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: DynCast,
fn unchecked_mut<T>(&mut self) -> &mut Twhere
T: DynCast,
fn is_instance_of<T>(&self) -> boolwhere
T: DynCast,
Source§fn is_type_of(val: &Val) -> bool
fn is_type_of(val: &Val) -> bool
instanceof.