Skip to content

Commit

Permalink
Fire "pagevisibility" events explicitly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
noamr committed Oct 15, 2021
1 parent 5d515fa commit 48de1dc
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -88419,13 +88419,9 @@ new PaymentRequest(…); // Allowed to use

<li><p>Set <var>newDocument</var>'s <span>page showing</span> flag to true.</p></li>

<li>
<p>Run any <dfn>session history document visibility change steps</dfn> for
<var>newDocument</var> that are defined by <span>other applicable specifications</span>.</p>

<p class="note">This is specifically intended for use by <cite>Page Visibility</cite>. <ref
spec=PAGEVIS></p>
</li>
<li><p>Fire an event named <code data-x="">visibilitychange</code> at
<var>newDocument</var>, with its <code data-x="dom-Event-bubbles">bubbles</code> attribute
initialized to true.</p></li>

<li><p><span>Fire a page transition event</span> named <code
data-x="event-pageshow">pageshow</code> at <var>newDocument</var>'s <span>relevant global
Expand Down Expand Up @@ -88878,30 +88874,27 @@ dictionary <dfn dictionary>PageTransitionEventInit</dfn> : <span>EventInit</span

<li><p>Increase <var>document</var>'s <span>unload counter</span> by 1.</p></li>

<li><p>If <var>document</var>'s <span>page showing</span> flag is false, then jump to the
step labeled <i>unload event</i> below (i.e. skip firing the <code
data-x="event-pagehide">pagehide</code> event and don't rerun the <span>unloading document
visibility change steps</span>).</p></li>

<li><p>Set <var>document</var>'s <span>page showing</span> flag to false.</p></li>

<li><p>If the user agent does not intend to keep <var>document</var> alive
in a <span>session history entry</span> (such that it can be reused later on <span
data-x="traverse the history">history traversal</span>), set <var>document</var>'s
<i data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>

<li><p><span>Fire a page transition event</span> named <code
data-x="event-pagehide">pagehide</code> at <var>document</var>'s <span>relevant global
object</span> with <var>document</var>'s <i data-x="concept-document-salvageable">salvageable</i>
state.</p></li>

<li>
<p>Run any <dfn>unloading document visibility change steps</dfn> for <var>document</var> that
are defined by <span>other applicable specifications</span>.</p>
<p>If <var>document</var>'s <span>page showing</span> is true:

<p class="note">This is specifically intended for use by <cite>Page Visibility</cite>.
<ref spec=PAGEVIS></p>
</li>
<ol>
<li><p>Set <var>document</var>'s <span>page showing</span> flag to false.</p></li>

<li><p><span>Fire a page transition event</span> named <code
data-x="event-pagehide">pagehide</code> at <var>document</var>'s
<span>relevant global object</span> with <var>document</var>'s
<i data-x="concept-document-salvageable">salvageable</i> state.</p></li>

<li><p>Fire an event named <code data-x="">visibilitychange</code> at
<var>newDocument</var>, with its <code data-x="dom-Event-bubbles">bubbles</code> attribute
initialized to true.</p></li>
</ol>
</li>

<li><p>If <var>unloadTimingInfo</var> is not null, then set <var>unloadTimingInfo</var>'s
<span>unload event start time</span> to the <span>current high resolution time</span> given
Expand Down Expand Up @@ -126069,9 +126062,6 @@ INSERT INTERFACES HERE
<dt id="refsPAINTTIMING">[PAINTTIMING]</dt>
<dd><cite><a href="https://w3c.github.io/paint-timing/">Paint Timing</a></cite>, S. Panicker. W3C.</dd>

<dt id="refsPAGEVIS">[PAGEVIS]</dt>
<dd>(Non-normative) <cite><a href="https://w3c.github.io/page-visibility/">Page Visibility Level 2</a></cite>, I. Grigorik, A. Jain, J. Mann. W3C.</dd>

<dt id="refsPAYMENTREQUEST">[PAYMENTREQUEST]</dt>
<dd><cite><a href="https://w3c.github.io/payment-request/">Payment Request API</a></cite>, M. Cáceres, D. Wang, R. Solomakhin, I. Jacobs. W3C.</dd>

Expand Down

0 comments on commit 48de1dc

Please sign in to comment.