This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove event handling, as it's moving to the HTML spec. #73
Remove event handling, as it's moving to the HTML spec. #73
Changes from 3 commits
cc45c40
9af3913
544fc76
89e6977
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The events defined in HTML now seem to be run synchronously, which is not what was previously defined. Is this intentional? Do we know what implementations are doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTML spec only defines the event order in the cases of unload/page hide. Those have to be synchronous otherwise they will never be handled
What's not defined is the non standard firing of that event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTML spec now fires the events directly, rather than queueing a task for them (which is what this spec defined before this PR). It'd be good to have tests that verify that the events indeed fire synchronously.
Can you expand on "Those have to be synchronous otherwise they will never be handled"?
/cc @rakina
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
‘
visible algorithm before running the step to fire the
[=Window/pageshow=] event.’
that’s the equivalent line in the current spec… synchronous
if the document is being unloaded or suspended into BFcache, which are the cases handled by the HTML spec, when is the handler going to be called? The JS execution context is about to be gone…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-read the algorithm, and you're right. For the cases of history traversal and unload, the events fire synchronously. They are firing async in "other cases" (e.g. tab moved to the background, tab switcher, app switcher, etc), but those other cases are not currently well-defined...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://html.spec.whatwg.org/multipage/webappapis.html#rendering-opportunity seems to use "page is in the background" without defining it. At worst, maybe we can use something like "page switches from background to foreground" to call the right visibility events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whatwg/html#7238
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely remember other specifications relying on this. Worthwhile to dig through past commits to see why we added this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments on this issue say otherwise, but it's possible...
I think the discussion here went in the direction of using direct calls rather than hooks, I tend to support that - much more straightforward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see this already came up: #73 (comment)
Not saying we need to keep this, just that we need to give those specs a proper heads up.