On Tuesday, February 3, 2026 at 1:36:06 PM UTC+1 Chromestatus wrote:

*Contact emails*
[email protected]

*Explainer*
https://github.com/WICG/navigation-api/pull/294


A bit more details would be useful here.
Even reading 
through 
https://github.com/WICG/navigation-api?tab=readme-ov-file#precommit-handlers, 
the role of post-commit handlers, nor how does one define them today is not 
clear.

I *think* I have a vague idea, so let me try to take a stab and let me know 
if I got it right.
Currently a developer that wants to add a post-commit handler (or simply a 
`handler` in the current API) to e.g. send analytics that a navigation has 
happened, can do that using
```
navigation.addEventListener("navigate", e => {
   if (e.canIntercept) {
    const handler = sendAnalytics(e);
    e.intercept({ handler });
  }
});
```

When they want to do something pre-commit (e.g. cancel the navigation if 
the target URL doesn't lead to a cat video), they can do something like
```
navigation.addEventListener("navigate", e => {
   if (e.canIntercept) {
    const precommitHandler = verifyCatVideo(controller);
    e.intercept({ precommitHandler });
  }
});
```
They can even add both.

But when developers today want to add a post-commit (or "regular") handler 
as a result of some handler in the pre-commit, they have no way of doing 
that.

This proposal is to add an `addHandler` method to the precommit controller, 
that would enable to add such post-commit handlers.

Is that roughly accurate?

If so, what would be an example use-case of wanting to add a post-commit 
handler as a result of pre-commit logic? What information does the 
pre-commit handler have that a post-commit logic doesn't?
 



*Specification*
https://html.spec.whatwg.org/#dom-navigationprecommitcontroller-addhandler 

*Summary*
Currently when intercepting navigations with the `navigate` event, 
precommitHandlers and post-commit ordinary handlers are passed separately. 
This works well when there is only one or the other, but can be a bit 
clunky when the flow includes a precommitHandler that leads to a 
post-commit handler. This addition is a small ergonomic improvement that 
enables registering a post-commit handler while invoking a precommit 
handler. 

*Blink component*
Blink>DOM 
<https://issues.chromium.org/issues?q=customfield1222907:%22Blink%3EDOM%22>

*Web Feature ID*
navigation <https://webstatus.dev/features/navigation> 

*Motivation*
This is a small ergonomic fix to the API enabling a bit more flexibility. 

*Initial public proposal*
https://github.com/whatwg/html/issues/11956

*TAG review*
*No information provided* 

*TAG review status*
Pending 

*Risks*


*Interoperability and Compatibility*
None, new API 

*Gecko*: No signal

*WebKit*: No signal

*Web developers*: Positive This was initially raised by Jake Archibald when 
at Shopify.

*Other signals*:

*WebView application risks*

Does this intent deprecate or change behavior of existing APIs, such that 
it has potentially high risk for Android WebView-based applications? 
*No information provided* 


*Debuggability*
*No information provided* 

*Will this feature be supported on all six Blink platforms (Windows, Mac, 
Linux, ChromeOS, Android, and Android WebView)?*
Yes

*Is this feature fully tested by web-platform-tests 
<https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md>?*
Yes 


*Flag name on about://flags*
*No information provided* 

*Finch feature name*
NavigateEventAddHandlerOnPrecommit 

*Rollout plan*
Will ship enabled for all users

*Requires code in //chrome?*
False

*Tracking bug*
https://issues.chromium.org/issues/465487215

*Estimated milestones*
Shipping on desktop147 Shipping on Android147 Shipping on WebView147 

*Anticipated spec changes*

Open questions about a feature may be a source of future web compat or 
interop issues. Please list open issues (e.g. links to known github issues 
in the project for the feature specification) whose resolution may 
introduce web compat/interop risk (e.g., changing to naming or structure of 
the API in a non-backward-compatible way). 
*No information provided*

*Link to entry on the Chrome Platform Status*
https://chromestatus.com/feature/5176907844943872?gate=6492610946531328

This intent message was generated by Chrome Platform Status 
<https://chromestatus.com>. 

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/3cec78f8-ecb5-4b71-8ae3-a5bd0278cf11n%40chromium.org.

Reply via email to