Skip to content

Commit

Permalink
Move URL/history updating out of respondWith()
Browse files Browse the repository at this point in the history
This ensures that if multiple event handlers are in place, appHistory.current and location.href only update after they all have finished.

Part of #94.
  • Loading branch information
domenic committed Apr 23, 2021
1 parent e2d9f6b commit 857f65d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,6 @@ An {{AppHistoryNavigateEvent}} also has an associated {{Promise}}-or-null <dfn f
1. If [=this=]'s [=Event/canceled flag=] is set, then throw an "{{InvalidStateError}}" {{DOMException}}.
1. Set [=this=]'s [=Event/canceled flag=].
1. Set [=this=]'s [=AppHistoryNavigateEvent/navigation action promise=] to |newNavigationAction|.
1. If [=this=]'s {{AppHistoryNavigateEvent/navigationType}} attribute was initialized to "{{AppHistoryNavigationType/push}}" or "{{AppHistoryNavigationType/replace}}":
1. Let |isPush| be true if [=this=]'s {{AppHistoryNavigateEvent/navigationType}} attribute was initialized to "{{AppHistoryNavigationType/push}}"; otherwise, false.
1. Run the <a spec="HTML">URL and history update steps</a> given [=this=]'s [=relevant global object=]'s [=associated document=] and [=this=]'s [=AppHistoryNavigateEvent/destination URL=], with <i>[=URL and history update steps/serializedData=]</i> set to [=this=]'s [=AppHistoryNavigateEvent/classic history API serialized data=] and <i>[=URL and history update steps/isPush=]</i> set to |isPush|.
1. Otherwise:
1. <a spec="HTML">Traverse the history</a> of [=this=]'s [=relevant global object=]'s [=Window/browsing context=] to [=AppHistoryNavigateEvent/destination entry=].
</div>

<hr>
Expand Down Expand Up @@ -464,6 +459,12 @@ An {{AppHistoryNavigateEvent}} also has an associated {{Promise}}-or-null <dfn f
1. Let |result| be the result of [=dispatching=] |event| at |appHistory|.
1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is null, then return false.
<p class="note">This can occurr if an event listener disconnected the <{iframe}> corresponding to [=this=]'s [=relevant global object=].</p>
1. If |event|'s [=AppHistoryNavigateEvent/navigation action promise=] is non-null, then:
1. If |event|'s {{AppHistoryNavigateEvent/navigationType}} attribute was initialized to "{{AppHistoryNavigationType/push}}" or "{{AppHistoryNavigationType/replace}}":
1. Let |isPush| be true if |event|'s {{AppHistoryNavigateEvent/navigationType}} attribute was initialized to "{{AppHistoryNavigationType/push}}"; otherwise, false.
1. Run the <a spec="HTML">URL and history update steps</a> given |event|'s [=relevant global object=]'s [=associated document=] and |event|'s [=AppHistoryNavigateEvent/destination URL=], with <i>[=URL and history update steps/serializedData=]</i> set to |event|'s [=AppHistoryNavigateEvent/classic history API serialized data=] and <i>[=URL and history update steps/isPush=]</i> set to |isPush|.
1. Otherwise:
1. <a spec="HTML">Traverse the history</a> of |event|'s [=relevant global object=]'s [=Window/browsing context=] to [=AppHistoryNavigateEvent/destination entry=].
1. If |event|'s [=AppHistoryNavigateEvent/navigation action promise=] is non-null, or both |result| and |isSameDocument| are true, then:
1. If |event|'s [=AppHistoryNavigateEvent/navigation action promise=] is null, then set it to [=a promise resolved with=] undefined, created in |realm|.
1. [=promise/React=] to |event|'s [=AppHistoryNavigateEvent/navigation action promise=] with the following fulfillment steps:
Expand Down

0 comments on commit 857f65d

Please sign in to comment.