Skip to content

Commit d5c8e5c

Browse files
authored
Add sourceElement to NavigateEvent
The sourceElement is either the clicked link, the submitter button, or the submitted form if there was no submitter button. See https://github.com/WICG/navigation-api/blob/main/README.md#navigation-monitoring-and-interception for the original explainer.
1 parent a16b0e9 commit d5c8e5c

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

source

+46-19
Original file line numberDiff line numberDiff line change
@@ -25640,8 +25640,9 @@ document.body.appendChild(wbr);</code></pre>
2564025640
<li>
2564125641
<p><span>Navigate</span><!--DONAV hyperlink--> <var>targetNavigable</var> to
2564225642
<var>urlString</var> using <var>subject</var>'s <span>node document</span>, with <i
25643-
data-x="navigation-referrer-policy">referrerPolicy</i> set to <var>referrerPolicy</var> and <i
25644-
data-x="navigation-user-involvement">userInvolvement</i> set to <var>userInvolvement</var>.</p>
25643+
data-x="navigation-referrer-policy">referrerPolicy</i> set to <var>referrerPolicy</var>, <i
25644+
data-x="navigation-user-involvement">userInvolvement</i> set to <var>userInvolvement</var>,
25645+
and <i data-x="navigation-source-element">sourceElement</i> set to <var>subject</var>.</p>
2564525646

2564625647
<p class="note">Unlike many other types of navigations, following hyperlinks does not have
2564725648
special "<code data-x="NavigationHistoryBehavior-replace">replace</code>" behavior for when
@@ -25721,7 +25722,8 @@ document.body.appendChild(wbr);</code></pre>
2572125722
<var>navigation</var> with <i data-x="fire-navigate-download-destinationURL">destinationURL</i>
2572225723
set to <var>urlString</var>, <i
2572325724
data-x="fire-navigate-download-userInvolvement">userInvolvement</i> set to
25724-
<var>userInvolvement</var>, and <i data-x="fire-navigate-download-filename">filename</i> set to
25725+
<var>userInvolvement</var>, <i data-x="fire-navigate-download-sourceElement">sourceElement</i>
25726+
set to <var>subject</var>, and <i data-x="fire-navigate-download-filename">filename</i> set to
2572525727
<var>filename</var>.</p></li>
2572625728

2572725729
<li><p>If <var>continue</var> is false, then return.</p></li>
@@ -60152,6 +60154,7 @@ fur
6015260154
using the <code>form</code> element's <span>node document</span>, with <var
6015360155
data-x="navigation-hh">historyHandling</var> set to <var>historyHandling</var>, <i
6015460156
data-x="navigation-user-involvement">userInvolvement</i> set to <var>userInvolvement</var>,
60157+
<i data-x="navigation-source-element">sourceElement</i> set to <var>submitter</var>,
6015560158
<i data-x="navigation-referrer-policy">referrerPolicy</i> set to <var>referrerPolicy</var>,
6015660159
<i data-x="navigation-resource">documentResource</i> set to <var>postResource</var>, and <i
6015760160
data-x="navigation-form-data-entry-list">formDataEntryList</i> set to <var>entry
@@ -95383,6 +95386,7 @@ interface <dfn interface>NavigateEvent</dfn> : <span>Event</span> {
9538395386
readonly attribute DOMString? <span data-x="dom-NavigateEvent-downloadRequest">downloadRequest</span>;
9538495387
readonly attribute any <span data-x="dom-NavigateEvent-info">info</span>;
9538595388
readonly attribute boolean <span data-x="dom-NavigateEvent-hasUAVisualTransition">hasUAVisualTransition</span>;
95389+
readonly attribute Element? <span data-x="dom-NavigateEvent-sourceElement">sourceElement</span>;
9538695390

9538795391
undefined <span data-x="dom-NavigateEvent-intercept">intercept</span>(optional <span>NavigationInterceptOptions</span> options = {});
9538895392
undefined <span data-x="dom-NavigateEvent-scroll">scroll</span>();
@@ -95513,6 +95517,12 @@ callback <dfn callback>NavigationInterceptHandler</dfn> = <span data-x="idl-Prom
9551395517
dispatching this event. If true, the best user experience will be given if the author
9551495518
synchronously updates the DOM to the post-navigation state.</p></dd>
9551595519

95520+
<dt><code data-x=""><var>event</var>.<span subdfn data-x="dom-NavigateEvent-sourceElement">sourceElement</span></code></dt>
95521+
<dd><p>Returns the <code>Element</code> responsible for this navigation. This can be an
95522+
<code>a</code>or <code>area</code> element, a <span
95523+
data-x="concept-submit-button">submit button</span>, or a submitted <code>form</code>
95524+
element.</p></dd>
95525+
9551695526
<dt><code data-x=""><var>event</var>.<span subdfn data-x="dom-NavigateEvent-intercept">intercept</span>({ <span subdfn data-x="dom-NavigationInterceptOptions-handler">handler</span>, <span subdfn data-x="dom-NavigationInterceptOptions-focusReset">focusReset</span>, <span subdfn data-x="dom-NavigationInterceptOptions-scroll">scroll</span> })</code></dt>
9551795527
<dd>
9551895528
<p>Intercepts this navigation, preventing its normal handling and instead converting it into a
@@ -95617,9 +95627,11 @@ callback <dfn callback>NavigationInterceptHandler</dfn> = <span data-x="idl-Prom
9561795627
for="NavigateEvent"><code data-x="dom-NavigateEvent-formData">formData</code></dfn>, <dfn
9561895628
attribute for="NavigateEvent"><code
9561995629
data-x="dom-NavigateEvent-downloadRequest">downloadRequest</code></dfn>, <dfn attribute
95620-
for="NavigateEvent"><code data-x="dom-NavigateEvent-info">info</code></dfn>, and <dfn attribute
95630+
for="NavigateEvent"><code data-x="dom-NavigateEvent-info">info</code></dfn>, <dfn attribute
9562195631
for="NavigateEvent"><code
95622-
data-x="dom-NavigateEvent-hasUAVisualTransition">hasUAVisualTransition</code></dfn> attributes
95632+
data-x="dom-NavigateEvent-hasUAVisualTransition">hasUAVisualTransition</code></dfn>, and
95633+
<dfn attribute for="NavigateEvent"><code
95634+
data-x="dom-NavigateEvent-sourceElement">sourceElement</code></dfn> attributes
9562395635
must return the values they are initialized to.</p>
9562495636

9562595637
<p>The <dfn method for="NavigateEvent"><code
@@ -95932,7 +95944,8 @@ interface <dfn interface>NavigationDestination</dfn> {
9593295944
<li><p>Return the result of performing the <span>inner <code
9593395945
data-x="event-navigate">navigate</code> event firing algorithm</span> given
9593495946
<var>navigation</var>, "<code data-x="dom-NavigationType-traverse">traverse</code>",
95935-
<var>event</var>, <var>destination</var>, <var>userInvolvement</var>, null, and null.</p></li>
95947+
<var>event</var>, <var>destination</var>, <var>userInvolvement</var>, null, null, and
95948+
null.</p></li>
9593695949
</ol>
9593795950

9593895951
<p>To <dfn>fire a push/replace/reload <code data-x="event-navigate">navigate</code> event</dfn> at
@@ -95942,7 +95955,9 @@ interface <dfn interface>NavigationDestination</dfn> {
9594295955
data-x="fire-navigate-prr-isSameDocument"><var>isSameDocument</var></dfn>, an optional <span>user
9594395956
navigation involvement</span> <dfn
9594495957
data-x="fire-navigate-prr-userInvolvement"><var>userInvolvement</var></dfn> (default "<code
95945-
data-x="uni-none">none</code>"), an optional <span>entry list</span>-or-null <dfn
95958+
data-x="uni-none">none</code>"), an optional <code>Element</code>-or-null <dfn
95959+
data-x="fire-navigate-prr-sourceElement"><var>sourceElement</var></dfn> (default null), an
95960+
optional <span>entry list</span>-or-null <dfn
9594695961
data-x="fire-navigate-prr-formDataEntryList"><var>formDataEntryList</var></dfn> (default null), an
9594795962
optional <span>serialized state</span> <dfn
9594895963
data-x="fire-navigate-prr-navigationAPIState"><var>navigationAPIState</var></dfn> (default
@@ -95980,14 +95995,17 @@ interface <dfn interface>NavigationDestination</dfn> {
9598095995
<li><p>Return the result of performing the <span>inner <code
9598195996
data-x="event-navigate">navigate</code> event firing algorithm</span> given
9598295997
<var>navigation</var>, <var>navigationType</var>, <var>event</var>, <var>destination</var>,
95983-
<var>userInvolvement</var>, <var>formDataEntryList</var>, and null.</p></li>
95998+
<var>userInvolvement</var>, <var>sourceElement</var>, <var>formDataEntryList</var>, and
95999+
null.</p></li>
9598496000
</ol>
9598596001

9598696002
<p>To <dfn>fire a download request <code data-x="event-navigate">navigate</code> event</dfn> at a
9598796003
<code>Navigation</code> <var>navigation</var> given a <span>URL</span> <dfn
9598896004
data-x="fire-navigate-download-destinationURL"><var>destinationURL</var></dfn>, a <span>user
9598996005
navigation involvement</span> <dfn
95990-
data-x="fire-navigate-download-userInvolvement"><var>userInvolvement</var></dfn>, and a string
96006+
data-x="fire-navigate-download-userInvolvement"><var>userInvolvement</var></dfn>, an
96007+
<code>Element</code>-or-null <dfn
96008+
data-x="fire-navigate-download-sourceElement"><var>sourceElement</var></dfn>, and a string
9599196009
<dfn data-x="fire-navigate-download-filename"><var>filename</var></dfn>:</p>
9599296010

9599396011
<ol>
@@ -96019,15 +96037,17 @@ interface <dfn interface>NavigationDestination</dfn> {
9601996037
<li><p>Return the result of performing the <span>inner <code
9602096038
data-x="event-navigate">navigate</code> event firing algorithm</span> given
9602196039
<var>navigation</var>, "<code data-x="dom-NavigationType-push">push</code>", <var>event</var>,
96022-
<var>destination</var>, <var>userInvolvement</var>, null, and <var>filename</var>.</p></li>
96040+
<var>destination</var>, <var>userInvolvement</var>, <var>sourceElement</var>, null, and
96041+
<var>filename</var>.</p></li>
9602396042
</ol>
9602496043

9602596044
<p>The <dfn>inner <code data-x="event-navigate">navigate</code> event firing algorithm</dfn>
9602696045
consists of the following steps, given a <code>Navigation</code> <var>navigation</var>, a
9602796046
<code>NavigationType</code> <var>navigationType</var>, a <code>NavigateEvent</code>
9602896047
<var>event</var>, a <code>NavigationDestination</code> <var>destination</var>, a <span>user
96029-
navigation involvement</span> <var>userInvolvement</var>, an <span>entry list</span>-or-null
96030-
<var>formDataEntryList</var>, and a string-or-null <var>downloadRequestFilename</var>:</p>
96048+
navigation involvement</span> <var>userInvolvement</var>, an <code>Element</code>-or-null
96049+
<var>sourceElement</var>, an <span>entry list</span>-or-null <var>formDataEntryList</var>, and a
96050+
string-or-null <var>downloadRequestFilename</var>:</p>
9603196051

9603296052
<ol>
9603396053
<li>
@@ -96149,6 +96169,10 @@ interface <dfn interface>NavigationDestination</dfn> {
9614996169
transition, to display a cached rendered state of the <var>document</var>'s <span>latest
9615096170
entry</span>, was done by the user agent. Otherwise, initialize it to false.</p></li>
9615196171

96172+
<li><p>Initialize <var>event</var>'s <code
96173+
data-x="dom-NavigateEvent-sourceElement">sourceElement</code> to
96174+
<var>sourceElement</var>.</p></li>
96175+
9615296176
<li><p>Set <var>event</var>'s <span data-x="concept-NavigateEvent-abort-controller">abort
9615396177
controller</span> to a <span>new</span> <code>AbortController</code> created in
9615496178
<var>navigation</var>'s <span data-x="concept-relevant-realm">relevant realm</span>.</p></li>
@@ -100364,9 +100388,10 @@ location.href = '#foo';</code></pre>
100364100388
null <dfn for="navigate" data-x="navigation-form-data-entry-list"
100365100389
export><var>formDataEntryList</var></dfn> (default null), an optional <span>referrer
100366100390
policy</span> <dfn data-x="navigation-referrer-policy"><var>referrerPolicy</var></dfn> (default
100367-
the empty string), and an optional <span>user navigation involvement</span> <dfn
100391+
the empty string), an optional <span>user navigation involvement</span> <dfn
100368100392
data-x="navigation-user-involvement"><var>userInvolvement</var></dfn> (default "<code
100369-
data-x="uni-none">none</code>"):</p>
100393+
data-x="uni-none">none</code>"), and an optional <code>Element</code> <dfn
100394+
data-x="navigation-source-element"><var>sourceElement</var></dfn> (default null):</p>
100370100395

100371100396
<ol>
100372100397
<li><p>Let <var>cspNavigationType</var> be "<code data-x="">form-submission</code>" if
@@ -100486,7 +100511,7 @@ location.href = '#foo';</code></pre>
100486100511
<ol>
100487100512
<li><p><span data-x="navigate-fragid">Navigate to a fragment</span> given <var>navigable</var>,
100488100513
<var>url</var>, <var>historyHandling</var>, <var>userInvolvement</var>,
100489-
<var>navigationAPIState</var>, and <var>navigationId</var>.</p></li>
100514+
<var>sourceElement</var>, <var>navigationAPIState</var>, and <var>navigationId</var>.</p></li>
100490100515

100491100516
<li><p>Return.</p></li>
100492100517
</ol>
@@ -100585,7 +100610,8 @@ location.href = '#foo';</code></pre>
100585100610
data-x="fire-navigate-prr-navigationType">navigationType</i> set to <var>historyHandling</var>,
100586100611
<i data-x="fire-navigate-prr-isSameDocument">isSameDocument</i> set to false, <i
100587100612
data-x="fire-navigate-prr-userInvolvement">userInvolvement</i> set to
100588-
<var>userInvolvement</var>, <i
100613+
<var>userInvolvement</var>, <i data-x="fire-navigate-prr-sourceElement">sourceElement</i> set
100614+
to <var>sourceElement</var>, <i
100589100615
data-x="fire-navigate-prr-formDataEntryList">formDataEntryList</i> set to
100590100616
<var>entryListForFiring</var>, <i data-x="fire-navigate-prr-destinationURL">destinationURL</i>
100591100617
set to <var>url</var>, and <i
@@ -101182,8 +101208,8 @@ location.href = '#foo';</code></pre>
101182101208
<p>To <dfn data-x="navigate-fragid">navigate to a fragment</dfn> given a <span>navigable</span>
101183101209
<var>navigable</var>, a <span>URL</span> <var>url</var>, a <span>history handling behavior</span>
101184101210
<var>historyHandling</var>, a <span>user navigation involvement</span> <var>userInvolvement</var>,
101185-
a <span>serialized state</span>-or-null <var>navigationAPIState</var>, and a <span>navigation
101186-
ID</span> <var>navigationId</var>:</p>
101211+
an <code>Element</code>-or-null <var>sourceElement</var>, a <span>serialized state</span>-or-null
101212+
<var>navigationAPIState</var>, and a <span>navigation ID</span> <var>navigationId</var>:</p>
101187101213

101188101214
<ol>
101189101215
<li><p>Let <var>navigation</var> be <var>navigable</var>'s <span data-x="nav-window">active
@@ -101201,7 +101227,8 @@ location.href = '#foo';</code></pre>
101201101227
<var>navigation</var> with <i data-x="fire-navigate-prr-navigationType">navigationType</i> set to
101202101228
<var>historyHandling</var>, <i data-x="fire-navigate-prr-isSameDocument">isSameDocument</i> set
101203101229
to true, <i data-x="fire-navigate-prr-userInvolvement">userInvolvement</i> set to
101204-
<var>userInvolvement</var>, <i data-x="fire-navigate-prr-destinationURL">destinationURL</i>
101230+
<var>userInvolvement</var>, <i data-x="fire-navigate-prr-sourceElement">sourceElement</i> set
101231+
to <var>sourceElement</var>, <i data-x="fire-navigate-prr-destinationURL">destinationURL</i>
101205101232
set to <var>url</var>, and <i
101206101233
data-x="fire-navigate-prr-navigationAPIState">navigationAPIState</i> set to
101207101234
<var>destinationNavigationAPIState</var>.</p></li>

0 commit comments

Comments
 (0)