pub struct MockDom {
pub root: DomElement,
/* private fields */
}Expand description
Mock DOM for testing WASM calculator without browser
Fields§
§root: DomElementRoot element
Implementations§
Source§impl MockDom
impl MockDom
Sourcepub fn calculator() -> Self
pub fn calculator() -> Self
Creates a calculator DOM structure
Sourcepub fn register_element(&mut self, element: DomElement)
pub fn register_element(&mut self, element: DomElement)
Registers an element for ID lookup
Sourcepub fn get_element(&self, id: &str) -> Option<&DomElement>
pub fn get_element(&self, id: &str) -> Option<&DomElement>
Gets an element by ID
Sourcepub fn get_element_mut(&mut self, id: &str) -> Option<&mut DomElement>
pub fn get_element_mut(&mut self, id: &str) -> Option<&mut DomElement>
Gets a mutable element by ID
Sourcepub fn dispatch_event(&mut self, event: DomEvent)
pub fn dispatch_event(&mut self, event: DomEvent)
Dispatches an event
Sourcepub fn event_history(&self) -> &[DomEvent]
pub fn event_history(&self) -> &[DomEvent]
Gets the event history
Sourcepub fn clear_event_history(&mut self)
pub fn clear_event_history(&mut self)
Clears event history
Sourcepub fn focused_element(&self) -> Option<&str>
pub fn focused_element(&self) -> Option<&str>
Gets the currently focused element ID
Sourcepub fn set_element_text(&mut self, id: &str, text: &str)
pub fn set_element_text(&mut self, id: &str, text: &str)
Updates element text by ID
Sourcepub fn get_element_text(&self, id: &str) -> Option<&str>
pub fn get_element_text(&self, id: &str) -> Option<&str>
Gets element text by ID
Sourcepub fn append_child(&mut self, parent_id: &str, child: DomElement)
pub fn append_child(&mut self, parent_id: &str, child: DomElement)
Adds a child element to a parent
Sourcepub fn clear_children(&mut self, id: &str)
pub fn clear_children(&mut self, id: &str)
Clears children of an element
Trait Implementations§
Source§impl MockDomKeypadExt for MockDom
impl MockDomKeypadExt for MockDom
Source§fn add_keypad(&mut self, keypad: &WasmKeypad)
fn add_keypad(&mut self, keypad: &WasmKeypad)
Adds keypad to an existing calculator DOM
Auto Trait Implementations§
impl Freeze for MockDom
impl RefUnwindSafe for MockDom
impl Send for MockDom
impl Sync for MockDom
impl Unpin for MockDom
impl UnsafeUnpin for MockDom
impl UnwindSafe for MockDom
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more