Skip to content

Commit 69ccb5d

Browse files
noamrzcorpan
authored andcommitted
Editorial: consolidate navigation API abort paths
Use "Inform the navigation API about aborting navigation" when possible Refactor it to loop and abort navigation until the event is nullified. Closes #11579
1 parent 783282e commit 69ccb5d

File tree

1 file changed

+35
-41
lines changed

1 file changed

+35
-41
lines changed

source

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100244,10 +100244,38 @@ const p2 = navigation.navigate(url2).finished;</code></pre>
100244100244
<li><p>Let <var>navigation</var> be <var>navigable</var>'s <span data-x="nav-window">active
100245100245
window</span>'s <span data-x="window-navigation-api">navigation API</span>.</p></li>
100246100246

100247-
<li><p>If <var>navigation</var>'s <span>ongoing <code data-x="event-navigate">navigate</code>
100248-
event</span> is null, then return.</p></li>
100247+
<li>
100248+
<p><span>While</span> <var>navigation</var>'s <span>ongoing <code
100249+
data-x="event-navigate">navigate</code> event</span> is not null:</p>
100250+
100251+
<ol>
100252+
<li><p><span>Abort the ongoing navigation</span> given <var>navigation</var>.</p></li>
100253+
</ol>
100254+
100255+
<div class="note">
100256+
<p>If there is an ongoing cross-document navigation, this means it will be signaled to the
100257+
navigation API as aborted, e.g., by firing <code
100258+
data-x="event-navigateerror">navigateerror</code> events. This is somewhat accurate, since the
100259+
next navigation the <code>Document</code> experiences will be this same-document navigation, so
100260+
a developer which was expecting the next navigation completion to be that of the cross-document
100261+
navigation gets a useful signal that this did not happen. However, it is also somewhat
100262+
inaccurate, as the browser will continue to process the ongoing cross-document navigation
100263+
(applying it after this same-document one synchronously finishes).</p>
100264+
100265+
<p>Ultimately, the navigation API gets a bit messy with overlapping cross- and same-document
100266+
navigations, as the <a href="#ongoing-navigation-tracking">ongoing navigation tracking</a>
100267+
machinery and APIs are built to expose only a single ongoing navigation. Web developers will be
100268+
best-served if they do not create such overlapping situations, e.g., by <code
100269+
data-x="">await</code>ing promises returned from <code
100270+
data-x="dom-Navigation-navigate">navigation.navigate()</code> before starting new
100271+
navigations.</p>
100272+
</div>
100249100273

100250-
<li><p><span>Abort the ongoing navigation</span> given <var>navigation</var>.</p></li>
100274+
<p class="note">This is a loop, since <span>abort the ongoing navigation</span> can run
100275+
JavaScript (e.g., via the <code data-x="event-navigateerror">navigateerror</code> event), which
100276+
might start a new navigation. Since such a newly-started navigation will be superseded by the
100277+
completion of this navigation, it gets signaled to the navigation API as aborted.</p>
100278+
</li>
100251100279
</ol>
100252100280
</div>
100253100281

@@ -101286,44 +101314,10 @@ interface <dfn interface>NavigationDestination</dfn> {
101286101314
null):</p>
101287101315

101288101316
<ol>
101289-
<li>
101290-
<p>If <var>isSameDocument</var> is true:</p>
101291-
101292-
<ol>
101293-
<li>
101294-
<p><span>While</span> <var>navigation</var>'s <span>ongoing <code
101295-
data-x="event-navigate">navigate</code> event</span> is not null:</p>
101296-
101297-
<ol>
101298-
<li><p><span>Abort the ongoing navigation</span> given <var>navigation</var>.</p></li>
101299-
</ol>
101300-
101301-
<div class="note">
101302-
<p>If there is an ongoing cross-document navigation, this means it will be signaled to the
101303-
navigation API as aborted, e.g., by firing <code
101304-
data-x="event-navigateerror">navigateerror</code> events. This is somewhat accurate, since
101305-
the next navigation the <code>Document</code> experiences will be this same-document
101306-
navigation, so a developer which was expecting the next navigation completion to be that of
101307-
the cross-document navigation gets a useful signal that this did not happen. However, it is
101308-
also somewhat inaccurate, as the browser will continue to process the ongoing cross-document
101309-
navigation (applying it after this same-document one synchronously finishes).</p>
101310-
101311-
<p>Ultimately, the navigation API gets a bit messy with overlapping cross- and same-document
101312-
navigations, as the <a href="#ongoing-navigation-tracking">ongoing navigation tracking</a>
101313-
machinery and APIs are built to expose only a single ongoing navigation. Web developers will
101314-
be best-served if they do not create such overlapping situations, e.g., by <code
101315-
data-x="">await</code>ing promises returned from <code
101316-
data-x="dom-Navigation-navigate">navigation.navigate()</code> before starting new
101317-
navigations.</p>
101318-
</div>
101319-
101320-
<p class="note">This is a loop, since <span>abort the ongoing navigation</span> can run
101321-
JavaScript (e.g., via the <code data-x="event-navigateerror">navigateerror</code> event),
101322-
which might start a new navigation. Since such a newly-started navigation will be superseded
101323-
by the completion of this navigation, it gets signaled to the navigation API as aborted.</p>
101324-
</li>
101325-
</ol>
101326-
</li>
101317+
<li><p><span>Inform the navigation API about aborting navigation</span> in
101318+
<var>navigation</var>'s <span>relevant global object</span>'s <span
101319+
data-x="concept-document-window">associated <code>Document</code></span>'s <span>node
101320+
navigable</span>.</p></li>
101327101321

101328101322
<li><p>Let <var>event</var> be the result of <span>creating an event</span> given
101329101323
<code>NavigateEvent</code>, in <var>navigation</var>'s <span

0 commit comments

Comments
 (0)