beforeunload and unload infrastructure

This commit is contained in:
Gregory Terzian 2018-03-18 13:20:24 +08:00
parent a1d1b18710
commit 427eaed535
28 changed files with 267 additions and 60 deletions

View file

@ -187,22 +187,21 @@ impl CompiledEventListener {
CommonEventHandler::BeforeUnloadEventHandler(ref handler) => {
if let Some(event) = event.downcast::<BeforeUnloadEvent>() {
let rv = event.ReturnValue();
// Step 5
if let Ok(value) = handler.Call_(object,
event.upcast::<Event>(),
exception_handle) {
match value {
Some(value) => {
if rv.is_empty() {
event.SetReturnValue(value);
}
}
None => {
event.upcast::<Event>().PreventDefault();
let rv = event.ReturnValue();
if let Some(v) = value {
if rv.is_empty() {
event.SetReturnValue(v);
}
event.upcast::<Event>().PreventDefault();
}
}
} else {
// Step 5, "Otherwise" clause
let _ = handler.Call_(object, event.upcast::<Event>(), exception_handle);
}
}