Feat: some code health

This commit is contained in:
Jonathan Kelley committed 2021-05-16 02:06:02 -04:00
1 parent 9810feebf5
commit c28697e1fe
16 files changed
+568 -551

No files matched your search

+4 -3
View File
@@ -58,8 +58,8 @@ pub mod on {
use crate::{
builder::ElementBuilder,
context::NodeCtx,
innerlude::{Attribute, Listener, VNode},
virtual_dom::NodeCtx,
};
use super::VirtualEvent;
@@ -77,11 +77,12 @@ pub mod on {
c: &'_ NodeCtx<'a>,
callback: impl Fn($eventdata) + 'a,
) -> Listener<'a> {
let bump = &c.bump();
Listener {
event: stringify!($name),
id: *c.idx.borrow(),
scope: c.scope,
callback: c.bump.alloc(move |evt: VirtualEvent| match evt {
scope: c.scope_ref.myidx,
callback: bump.alloc(move |evt: VirtualEvent| match evt {
VirtualEvent::$eventdata(event) => callback(event),
_ => {
unreachable!("Downcasted VirtualEvent to wrong event type - this is a bug!")