use rong::{function::*, *};
#[derive(FromJSObj, Default)]
pub struct EventOptions {
#[js_default]
pub bubbles: bool,
#[js_default]
pub cancelable: bool,
#[js_default]
pub composed: bool,
}
#[js_export]
#[derive(Default)]
pub struct Event {
pub(crate) type_: String,
bubbles: bool,
cancelable: bool,
composed: bool,
}
#[js_class]
impl Event {
#[js_method(constructor)]
pub(crate) fn new(type_: String, options: Optional<EventOptions>) -> Self {
let opts = options.0.unwrap_or_default();
Self {
type_,
bubbles: opts.bubbles,
cancelable: opts.cancelable,
composed: opts.composed,
}
}
#[js_method(getter, rename = "type")]
pub(crate) fn type_(&self) -> String {
self.type_.clone()
}
#[js_method(getter)]
pub(crate) fn bubbles(&self) -> bool {
self.bubbles
}
#[js_method(getter)]
pub(crate) fn cancelable(&self) -> bool {
self.cancelable
}
#[js_method(getter)]
pub(crate) fn composed(&self) -> bool {
self.composed
}
#[js_method(gc_mark)]
fn gc_mark_with<F>(&self, _mark_fn: F)
where
F: FnMut(&JSValue),
{
}
}