Skip to main content

afia_component/
attribute.rs

1use crate::dom::element::DomElement;
2
3impl DomElement {
4    /// Set an attribute on the DOM element.
5    pub fn set_attribute(&self, key: &str, value: &str) {
6        unsafe {
7            afia_component_sys::dom_element_set_attribute(
8                self.component_imports_ptr(),
9                self.to_i64(),
10                key.as_ptr(),
11                key.len(),
12                value.as_ptr(),
13                value.len(),
14            )
15        };
16    }
17
18    /// Remove an attribute from the DOM element.
19    pub fn remove_attribute(&self, key: &str) {
20        unsafe {
21            afia_component_sys::dom_element_remove_attribute(
22                self.component_imports_ptr(),
23                self.to_i64(),
24                key.as_ptr(),
25                key.len(),
26            )
27        };
28    }
29}