Skip to content

Commit 28c09f8

Browse files
committed
DomBackend::setup_mouse_event_handler with debug_assserts
1 parent 0fa93e5 commit 28c09f8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/backend/dom.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ impl DomBackendOptions {
7373
///
7474
/// In other words, it transforms the [`Cell`]s into `<span>`s which are then
7575
/// appended to a `<pre>` element.
76-
#[derive(Debug)]
7776
pub struct DomBackend {
7877
/// Whether the backend has been initialized.
7978
initialized: Rc<RefCell<bool>>,
@@ -199,12 +198,13 @@ impl DomBackend {
199198
let grid_rect = (rect.left(), rect.top(), rect.width(), rect.height());
200199
handler.call(MouseEvent::new_relative(event, cell_size_px, grid_rect));
201200
} else {
202-
// Fallback to viewport-relative coordinates if we can't get the element
203-
handler.call(MouseEvent::new(event, cell_size_px));
201+
// this will maybe not happen, but if it does, we panic in dev
202+
// but ignore it in release builds. to be fixed if it happens.
203+
debug_assert!(false, "target is no longer a valid element");
204204
}
205205
} else {
206-
// Fallback to viewport-relative coordinates if no target
207-
handler.call(MouseEvent::new(event, cell_size_px));
206+
// same as above, this will maybe not happen, but if it does, we should fix it
207+
debug_assert!(false, "no current target for mouse event");
208208
}
209209
}) as Box<dyn FnMut(web_sys::MouseEvent)>);
210210

src/event.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use crate::event::MouseButton::Left;
2-
31
/// A key event.
42
#[derive(Debug, Clone, Eq, PartialEq)]
53
pub struct KeyEvent {

0 commit comments

Comments
 (0)