-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firing "page exit" events on portal activation #225
Comments
To be clear, you'd be firing it on the page that's being "taken over"? If so, that makes sense to me. |
Yep! |
I guess we might want to limit ourselves to just pagehide since unload/beforeunload are kind of deprecated? But maybe this isn't the right place to make that stand, and asymmetry would just be confusing... Would we allow unload/beforeunload handlers to cancel the event? And in the beforeunload case, would canceling cause the prompt? |
|
I'll double check, but I think unload does fire on pages going into the bfcache, although it isn't salvageable if there's a single unload listener. Having said that, I think Safari does something different. |
haraken was wondering offline that since unload handlers are already unreliable, whether it would make sense to standardize portals to unconditionally not run unload handlers. The three possibilities for the predecessor following activation are:
Of course, (3) assumes the user agent fires unload in the conventional case. See https://docs.google.com/document/d/19n-DYAFzw1aIYPfVL07246Nf640QvSPUctUajI5hSgs/edit?usp=sharing for how bfcache interacts with unload handlers in chrome. It seems like it would be easier to reason about "portal activation never fires unload" over "portal activation fires unload unless the page is adopted or eligible for bfcache, or the user agent chooses not to." But as domenic suggested above, making that change would introduce inconsistency with conventional navigations. beforeunload probably still makes sense to fire. Canceling the event would presumably cause the activate promise to reject. However if the behaviour described in the above link is still accurate, safari mobile might choose to not do that. |
We've since updated the spec to match Chrome and Safari, which do not fire unload for cases where a page goes into the bfcache: whatwg/html@b3b7add I like the idea of never firing unload for portal activations. It seems to be on the way out; there's various work ongoing to deprecate it, in general. However, we do need to be sure to fire pagehide/pageshow, since those are the recommended replacements. I'm not a big fan of beforeunload either, but the tradeoff for breaking it is not as good, probably. So keeping it seems reasonable to me. /cc @rakina |
I'm looking to make portal activations more like navigations, and part of this would be to fire the pagehide, unload event etc etc before a portal can fully activate. Any objection to this?
If we do that, it seems like
portal.activate()
should fulfill in the same task as those events.The text was updated successfully, but these errors were encountered: