-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fire "visibilitychange" events explicitly #7153
Conversation
Make sure "pagevisibility" is also defined in https://html.spec.whatwg.org/multipage/indices.html#events-2 |
@domenic r? |
Are there any tests for this? |
Oh, the event name is "visibilitychange", I'll update the PR description. |
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.
This is wonderful.
Are there tests with regard to the relative order between visibilitychange and pagehide/pageshow? |
Some other possible test gaps (but maybe I just can't find the tests):
I don't think we necessarily need to block on total coverage, given that this is a refactoring, but it might be good to avoid busywork if we need to go back and correct things later. |
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, found a potentially big missing piece: the definition of onvisibilitychange
.
It looks like this is a special Document
-only event handler, like onreadystatechange
. So I'd search for the two places onreadystatechange
shows up and add it to those.
It exists in the |
Fire the event when unloading or traversing history, instead of relying on hooks in other specs. See w3c/page-visibility#51 and w3c/page-visibility#73
Done in new PR version. |
You also need to add it to |
Done |
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 was going to fix the spacing issue myself and merge, but then I saw the reference issue.
<ref spec=PAGEVIS></p> | ||
</li> | ||
<ol> | ||
<li><p>Set <var>document</var>'s <span>page showing</span> flag to false.</p></li> |
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.
This is two-space indents, but it should be 1-space.
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.
Fixed
<td> <dfn event for="Document"><code data-x="event-visibilitychange">visibilitychange</code></dfn> | ||
<td> <code>Event</code> | ||
<td> <code>Document</code> | ||
<td> Fired at the <code>Document</code> object when the page becomes visible or hidden to the user. [[PAGEVIS]] |
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.
This will just produce the literal text [[PAGEVIS]]
in the output. In HTML you need to use <ref spec=PAGEVIS>
. (And, if you do that, you need to not delete the reference on line 126072.)
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.
Fixed
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.
Great, thanks so much; this is way cleaner.
Fire the event when unloading or traversing history,
instead of relying on hooks in other specs.
See w3c/page-visibility#51
and w3c/page-visibility#73
At least two implementers are interested (and none opposed):
Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
(See WHATWG Working Mode: Changes for more details.)
/browsing-the-web.html ( diff )
/dom.html ( diff )
/indices.html ( diff )
/webappapis.html ( diff )