Skip to content

Commit a192047

Browse files
authored
Rename commit: "manual" to "after-transition"
As such, call the feature "deferred commit" instead of "manual commit". See discussion in #66 (comment).
1 parent 4b4e33b commit a192047

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ backButtonEl.addEventListener("click", () => {
7474
- [Focus management](#focus-management)
7575
- [Scrolling to fragments and scroll resetting](#scrolling-to-fragments-and-scroll-resetting)
7676
- [Scroll position restoration](#scroll-position-restoration)
77-
- [Manual commit](#manual-commit)
77+
- [Deferred commit](#deferred-commit)
7878
- [Transitional time after navigation interception](#transitional-time-after-navigation-interception)
7979
- [Example: handling failed navigations](#example-handling-failed-navigations)
8080
- [The `navigate()` and `reload()` methods](#the-navigate-and-reload-methods)
@@ -276,7 +276,7 @@ All of these methods return `{ committed, finished }` pairs, where both values a
276276
277277
- The `navigate` event responds to the navigation using `event.intercept()` with a `commit` option of `"immediate"` (the default). In this case the `committed` promise immediately fulfills, while the `finished` promise fulfills or rejects according to any promise(s) returned by handlers passed to `intercept()`. (However, even if the `finished` promise rejects, `location.href` and `navigation.currentEntry` will change.)
278278
279-
- The `navigate` event listener responds to the navigation using `event.intercept()` with a `commit` option of `"manual"`. In this case the `committed` promise fulfills and `location.href` and `navigation.currentEntry` change when `event.commit()` is called. The `finished` promise fulfills or rejects according to any promise(s) returned by handlers passed to `intercept()`. If a promise returned by a handler rejects before `event.commit()` is called, then both the `committed` and `finished` promises reject and `location.href` and `navigation.currentEntry` do not update. If all promise(s) returned by handlers fulfill, but the `committed` promise has not yet fulfilled, the `committed` promise will be fulfilled and and `location.href` and `navigation.currentEntry` will be updated first, then `finished` will fulfill.
279+
- The `navigate` event listener responds to the navigation using `event.intercept()` with a `commit` option of `"after-transition"`. In this case the `committed` promise fulfills and `location.href` and `navigation.currentEntry` change when `event.commit()` is called. The `finished` promise fulfills or rejects according to any promise(s) returned by handlers passed to `intercept()`. If a promise returned by a handler rejects before `event.commit()` is called, then both the `committed` and `finished` promises reject and `location.href` and `navigation.currentEntry` do not update. If all promise(s) returned by handlers fulfill, but the `committed` promise has not yet fulfilled, the `committed` promise will be fulfilled and and `location.href` and `navigation.currentEntry` will be updated first, then `finished` will fulfill.
280280
281281
- The navigation succeeds, and was a same-document navigation (but not intercepted using `event.intercept()`). Then both promises immediately fulfill, and `location.href` and `navigation.currentEntry` will have been set to their new value.
282282
@@ -333,15 +333,15 @@ Note that you can check if the navigation will be [same-document or cross-docume
333333
The event object has a special method `event.intercept(options)`. This works only under certain circumstances, e.g. it cannot be used on cross-origin navigations. ([See below](#restrictions-on-firing-canceling-and-responding) for full details.) It will:
334334
335335
- Cancel any fragment navigation or cross-document navigation.
336-
- Immediately update the URL bar, `location.href`, and `navigation.currentEntry` unless the `event.intercept()` was called with a `commit` option of `"manual"`.
336+
- Immediately update the URL bar, `location.href`, and `navigation.currentEntry` unless the `event.intercept()` was called with a `commit` option of `"after-transition"`.
337337
- Create the [`navigation.transition`](#transitional-time-after-navigation-interception) object.
338338
- If `options.handler` is given, it can be a function that returns a promise. That function will be then be called, and the browser will wait for the returned promise to settle. Once it does, the browser will:
339339
- If the promise rejects, fire `navigateerror` on `navigation` and reject `navigation.transition.finished`.
340340
- If the promise fulfills, fire `navigatesuccess` on `navigation` and fulfill `navigation.transition.finished`.
341341
- Set `navigation.transition` to null.
342342
- For the duration of any such promise settling, any browser loading UI such as a spinner will behave as if it were doing a cross-document navigation.
343343
344-
Note that the browser does not wait for any returned promises to settle in order to update its URL/history-displaying UI (such as URL bar or back button), or to update `location.href` and `navigation.currentEntry`, unless a `commit` option of `"manual"` is provided to `event.intercept()`. [See below](#manual-commit) for more details.
344+
Note that the browser does not wait for any returned promises to settle in order to update its URL/history-displaying UI (such as URL bar or back button), or to update `location.href` and `navigation.currentEntry`, unless a `commit` option of `"after-transition"` is provided to `event.intercept()`. [See below](#deferred-commit) for more details.
345345
346346
If `intercept()` is called multiple times (e.g., by multiple different listeners to the `navigate` event), then all of the promises returned by any handlers will be combined together using the equivalent of `Promise.all()`, so that the navigation only counts as a success once they have all fulfilled, or the navigation counts as an error at the point where any of them reject.
347347
@@ -689,18 +689,18 @@ Some more details on how the navigation API handles scrolling with `"traverse"`
689689
690690
- By default, any navigations which are intercepted with `navigateEvent.intercept()` will _ignore_ the value of `history.scrollRestoration` from the classic history API. This allows developers to use `history.scrollRestoration` for controlling cross-document scroll restoration, while using the more-granular option to `intercept()` to control individual same-document navigations.
691691
692-
#### Manual commit
692+
#### Deferred commit
693693
694694
The default behavior of immediately "committing" (i.e., updating `location.href` and `navigation.currentEntry`) works well for most situations, but some developers may find they do not want to immediately update the URL, and may want to retain the option of aborting the navigation without needing to rollback a URL update or cancel-and-restart. This behavior can be customized using `intercept()`'s `commit` option:
695695

696696
- `e.intercept({ handler, commit: "immediate" })`: the default behavior, immediately commit the navigation and update `location.href` and `navigation.currentEntry`.
697-
- `e.intercept({ handler, commit: "manual" })`: start the navigation (e.g., show a loading spinner if the UI has one), but do not immediately commit.
697+
- `e.intercept({ handler, commit: "after-transition" })`: start the navigation (e.g., show a loading spinner if the UI has one), but do not immediately commit.
698698

699-
When manual commit is used, the navigation will commit (and a `committed` promise will resolve if present) when `e.commit()` is called. If any handler(s) passed to `intercept()` fulfill, and `e.commit()` has not yet been called, we will fallback to committing just before any `finish` promise resolves and `navigatesuccess` is fired.
699+
When deferred commit is used, the navigation will commit (and a `committed` promise will resolve if present) when `e.commit()` is called. If any handler(s) passed to `intercept()` fulfill, and `e.commit()` has not yet been called, we will fallback to committing just before any `finish` promise resolves and `navigatesuccess` is fired.
700700

701701
If a handler passed to `intercept()` rejects before `e.commit()` is called, then the navigation will be treated as canceled (both `committed` and `finished` promises will reject, and no URL update will occur). If a handler passed to `intercept()` rejects after `e.commit()` is called, the behavior will match a rejected promise in immediate commit mode (i.e., the `committed` promise will fulfill, the `finished` promise will reject, and the URL will update).
702702

703-
Because manual commit can be used to cancel the navigation before the URL updates, it is only available when `e.cancelable` is true. See [above](#restrictions-on-firing-canceling-and-responding) for details on when `e.cancelable` is set to false, and thus manual commit is not available.
703+
Because deferred commit can be used to cancel the navigation before the URL updates, it is only available when `e.cancelable` is true. See [above](#restrictions-on-firing-canceling-and-responding) for details on when `e.cancelable` is set to false, and thus deferred commit is not available.
704704

705705
### Transitional time after navigation interception
706706

@@ -1001,7 +1001,7 @@ Between the `dispose` events, the `window.navigation` events, and various promis
10011001
1. `navigation.transition` is created.
10021002
1. If `event.intercept()` was not called, or `event.intercept()` was called with no `commit` option, or `event.intercept()` was called with a `commit` option of `immediate`, run the commit steps (see below).
10031003
1. Any loading spinner UI starts, if `event.intercept()` was called.
1004-
1. When `event.commit()` is called, if `event.intercept()` was called with a `commit` option of `"manual"`, run the commit steps (see below).
1004+
1. When `event.commit()` is called, if `event.intercept()` was called with a `commit` option of `"after-transition"`, run the commit steps (see below).
10051005
1. After all the promises returned by handlers passed to `event.intercept()` fulfill, or after one microtask if `event.intercept()` was not called:
10061006
1. If the commit steps (see below) have not run yet, run them now.
10071007
1. `navigatesuccess` is fired on `navigation`.

0 commit comments

Comments
 (0)