Stop overwriting prevent_default if default wasn't prevented

This didn't actually cause any issues because there is only one listener
for the affected methods right now. Should we have added more, the last
called observer would have overwritten `prevent_default`. Lets only set
it when necessary to avoid this footgun in the future.
This commit is contained in:
Birunthan Mohanathas 2018-04-19 12:39:17 +02:00
parent 6c9f3066fd
commit cd407d1c3f
2 changed files with 21 additions and 7 deletions

View file

@ -135,7 +135,9 @@ void TopLevelWindow::InitWith(v8::Isolate* isolate,
}
void TopLevelWindow::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
if (Emit("close")) {
*prevent_default = true;
}
}
void TopLevelWindow::OnWindowClosed() {