mirror of
https://github.com/jquery/jquery.git
synced 2026-02-06 19:05:12 -05:00
Fix #12061. Avoid window.onbeforeunload to permit multiple handlers. Close gh-894.
This commit is contained in:
13
src/event.js
13
src/event.js
@@ -549,16 +549,11 @@ jQuery.event = {
|
||||
},
|
||||
|
||||
beforeunload: {
|
||||
setup: function( data, namespaces, eventHandle ) {
|
||||
// We only want to do this special case on windows
|
||||
if ( jQuery.isWindow( this ) ) {
|
||||
this.onbeforeunload = eventHandle;
|
||||
}
|
||||
},
|
||||
postDispatch: function( event ) {
|
||||
|
||||
teardown: function( namespaces, eventHandle ) {
|
||||
if ( this.onbeforeunload === eventHandle ) {
|
||||
this.onbeforeunload = null;
|
||||
// Even when returnValue equals to undefined Firefox will still show alert
|
||||
if ( event.result !== undefined ) {
|
||||
event.originalEvent.returnValue = event.result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user