@angular/router 12.1.3 → 12.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/router-testing.umd.js +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router.umd.js +62 -30
- package/bundles/router.umd.js.map +1 -1
- package/esm2015/src/events.js +5 -3
- package/esm2015/src/router.js +56 -27
- package/esm2015/src/version.js +1 -1
- package/fesm2015/router.js +61 -30
- package/fesm2015/router.js.map +1 -1
- package/fesm2015/testing.js +1 -1
- package/fesm2015/upgrade.js +1 -1
- package/package.json +4 -4
- package/router.d.ts +10 -11
- package/router.metadata.json +1 -1
- package/testing/testing.d.ts +1 -1
- package/testing.d.ts +1 -1
- package/upgrade/upgrade.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/bundles/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.1.
|
|
2
|
+
* @license Angular v12.1.4
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -342,12 +342,14 @@
|
|
|
342
342
|
* The following code shows how a class subscribes to router events.
|
|
343
343
|
*
|
|
344
344
|
* ```ts
|
|
345
|
+
* import {Event, RouterEvent, Router} from '@angular/router';
|
|
346
|
+
*
|
|
345
347
|
* class MyService {
|
|
346
|
-
* constructor(public router: Router
|
|
348
|
+
* constructor(public router: Router) {
|
|
347
349
|
* router.events.pipe(
|
|
348
350
|
* filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
|
|
349
351
|
* ).subscribe((e: RouterEvent) => {
|
|
350
|
-
*
|
|
352
|
+
* // Do something
|
|
351
353
|
* });
|
|
352
354
|
* }
|
|
353
355
|
* }
|
|
@@ -4733,7 +4735,8 @@
|
|
|
4733
4735
|
_this.triggerEvent(guardsEnd);
|
|
4734
4736
|
}), operators.filter(function (t) {
|
|
4735
4737
|
if (!t.guardsResult) {
|
|
4736
|
-
_this.
|
|
4738
|
+
_this.restoreHistory(t);
|
|
4739
|
+
_this.cancelNavigationTransition(t, '');
|
|
4737
4740
|
return false;
|
|
4738
4741
|
}
|
|
4739
4742
|
return true;
|
|
@@ -4750,7 +4753,8 @@
|
|
|
4750
4753
|
next: function () { return dataResolved = true; },
|
|
4751
4754
|
complete: function () {
|
|
4752
4755
|
if (!dataResolved) {
|
|
4753
|
-
_this.
|
|
4756
|
+
_this.restoreHistory(t);
|
|
4757
|
+
_this.cancelNavigationTransition(t, "At least one route resolver didn't emit any value.");
|
|
4754
4758
|
}
|
|
4755
4759
|
}
|
|
4756
4760
|
}));
|
|
@@ -4816,7 +4820,8 @@
|
|
|
4816
4820
|
// AngularJS sync code which looks for a value here in order to determine
|
|
4817
4821
|
// whether or not to handle a given popstate event or to leave it to the
|
|
4818
4822
|
// Angular router.
|
|
4819
|
-
_this.
|
|
4823
|
+
_this.restoreHistory(t);
|
|
4824
|
+
_this.cancelNavigationTransition(t, cancelationReason);
|
|
4820
4825
|
}
|
|
4821
4826
|
else {
|
|
4822
4827
|
// We cannot trigger a `location.historyGo` if the
|
|
@@ -4835,6 +4840,17 @@
|
|
|
4835
4840
|
// we can safely set currentNavigation to null here.
|
|
4836
4841
|
_this.currentNavigation = null;
|
|
4837
4842
|
}), operators.catchError(function (e) {
|
|
4843
|
+
// TODO(atscott): The NavigationTransition `t` used here does not accurately
|
|
4844
|
+
// reflect the current state of the whole transition because some operations
|
|
4845
|
+
// return a new object rather than modifying the one in the outermost
|
|
4846
|
+
// `switchMap`.
|
|
4847
|
+
// The fix can likely be to:
|
|
4848
|
+
// 1. Rename the outer `t` variable so it's not shadowed all the time and
|
|
4849
|
+
// confusing
|
|
4850
|
+
// 2. Keep reassigning to the outer variable after each stage to ensure it
|
|
4851
|
+
// gets updated. Or change the implementations to not return a copy.
|
|
4852
|
+
// Not changed yet because it affects existing code and would need to be
|
|
4853
|
+
// tested more thoroughly.
|
|
4838
4854
|
errored = true;
|
|
4839
4855
|
/* This error type is issued during Redirect, and is handled as a
|
|
4840
4856
|
* cancellation rather than an error. */
|
|
@@ -4847,7 +4863,7 @@
|
|
|
4847
4863
|
// This is only applicable with initial navigation, so setting
|
|
4848
4864
|
// `navigated` only when not redirecting resolves this scenario.
|
|
4849
4865
|
_this.navigated = true;
|
|
4850
|
-
_this.
|
|
4866
|
+
_this.restoreHistory(t, true);
|
|
4851
4867
|
}
|
|
4852
4868
|
var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), e.message);
|
|
4853
4869
|
eventsSubject.next(navCancel);
|
|
@@ -4874,7 +4890,7 @@
|
|
|
4874
4890
|
* the pre-error state. */
|
|
4875
4891
|
}
|
|
4876
4892
|
else {
|
|
4877
|
-
_this.
|
|
4893
|
+
_this.restoreHistory(t, true);
|
|
4878
4894
|
var navError = new NavigationError(t.id, _this.serializeUrl(t.extractedUrl), e);
|
|
4879
4895
|
eventsSubject.next(navError);
|
|
4880
4896
|
try {
|
|
@@ -5335,42 +5351,58 @@
|
|
|
5335
5351
|
this.location.go(path, '', state);
|
|
5336
5352
|
}
|
|
5337
5353
|
};
|
|
5338
|
-
Router.prototype.resetStateAndUrl = function (storedState, storedUrl, rawUrl) {
|
|
5339
|
-
this.routerState = storedState;
|
|
5340
|
-
this.currentUrlTree = storedUrl;
|
|
5341
|
-
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
|
|
5342
|
-
this.resetUrlToCurrentUrlTree();
|
|
5343
|
-
};
|
|
5344
|
-
Router.prototype.resetUrlToCurrentUrlTree = function () {
|
|
5345
|
-
this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
|
|
5346
|
-
};
|
|
5347
5354
|
/**
|
|
5348
|
-
*
|
|
5349
|
-
*
|
|
5350
|
-
* state before the transition
|
|
5351
|
-
* - triggers the `NavigationCancel` event
|
|
5352
|
-
* - resolves the transition promise with `false`
|
|
5355
|
+
* Performs the necessary rollback action to restore the browser URL to the
|
|
5356
|
+
* state before the transition.
|
|
5353
5357
|
*/
|
|
5354
|
-
Router.prototype.
|
|
5358
|
+
Router.prototype.restoreHistory = function (t, restoringFromCaughtError) {
|
|
5359
|
+
if (restoringFromCaughtError === void 0) { restoringFromCaughtError = false; }
|
|
5360
|
+
var _a, _b;
|
|
5355
5361
|
if (this.canceledNavigationResolution === 'computed') {
|
|
5362
|
+
var targetPagePosition = this.currentPageId - t.targetPageId;
|
|
5356
5363
|
// The navigator change the location before triggered the browser event,
|
|
5357
5364
|
// so we need to go back to the current url if the navigation is canceled.
|
|
5358
5365
|
// Also, when navigation gets cancelled while using url update strategy eager, then we need to
|
|
5359
5366
|
// go back. Because, when `urlUpdateSrategy` is `eager`; `setBrowserUrl` method is called
|
|
5360
5367
|
// before any verification.
|
|
5361
|
-
|
|
5362
|
-
|
|
5368
|
+
var browserUrlUpdateOccurred = (t.source === 'popstate' || this.urlUpdateStrategy === 'eager' ||
|
|
5369
|
+
this.currentUrlTree === ((_a = this.currentNavigation) === null || _a === void 0 ? void 0 : _a.finalUrl));
|
|
5370
|
+
if (browserUrlUpdateOccurred && targetPagePosition !== 0) {
|
|
5363
5371
|
this.location.historyGo(targetPagePosition);
|
|
5364
5372
|
}
|
|
5373
|
+
else if (this.currentUrlTree === ((_b = this.currentNavigation) === null || _b === void 0 ? void 0 : _b.finalUrl) && targetPagePosition === 0) {
|
|
5374
|
+
// We got to the activation stage (where currentUrlTree is set to the navigation's
|
|
5375
|
+
// finalUrl), but we weren't moving anywhere in history (skipLocationChange or replaceUrl).
|
|
5376
|
+
// We still need to reset the router state back to what it was when the navigation started.
|
|
5377
|
+
this.resetState(t);
|
|
5378
|
+
// TODO(atscott): resetting the `browserUrlTree` should really be done in `resetState`.
|
|
5379
|
+
// Investigate if this can be done by running TGP.
|
|
5380
|
+
this.browserUrlTree = t.currentUrlTree;
|
|
5381
|
+
this.resetUrlToCurrentUrlTree();
|
|
5382
|
+
}
|
|
5365
5383
|
else {
|
|
5366
|
-
//
|
|
5367
|
-
//
|
|
5384
|
+
// The browser URL and router state was not updated before the navigation cancelled so
|
|
5385
|
+
// there's no restoration needed.
|
|
5368
5386
|
}
|
|
5369
5387
|
}
|
|
5370
|
-
else {
|
|
5388
|
+
else if (this.canceledNavigationResolution === 'replace') {
|
|
5389
|
+
// TODO(atscott): It seems like we should _always_ reset the state here. It would be a no-op
|
|
5390
|
+
// for `deferred` navigations that haven't change the internal state yet because guards
|
|
5391
|
+
// reject. For 'eager' navigations, it seems like we also really should reset the state
|
|
5392
|
+
// because the navigation was cancelled. Investigate if this can be done by running TGP.
|
|
5393
|
+
if (restoringFromCaughtError) {
|
|
5394
|
+
this.resetState(t);
|
|
5395
|
+
}
|
|
5371
5396
|
this.resetUrlToCurrentUrlTree();
|
|
5372
5397
|
}
|
|
5373
|
-
|
|
5398
|
+
};
|
|
5399
|
+
Router.prototype.resetState = function (t) {
|
|
5400
|
+
this.routerState = t.currentRouterState;
|
|
5401
|
+
this.currentUrlTree = t.currentUrlTree;
|
|
5402
|
+
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, t.rawUrl);
|
|
5403
|
+
};
|
|
5404
|
+
Router.prototype.resetUrlToCurrentUrlTree = function () {
|
|
5405
|
+
this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
|
|
5374
5406
|
};
|
|
5375
5407
|
Router.prototype.cancelNavigationTransition = function (t, reason) {
|
|
5376
5408
|
var navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), reason);
|
|
@@ -6695,7 +6727,7 @@
|
|
|
6695
6727
|
/**
|
|
6696
6728
|
* @publicApi
|
|
6697
6729
|
*/
|
|
6698
|
-
var VERSION = new core.Version('12.1.
|
|
6730
|
+
var VERSION = new core.Version('12.1.4');
|
|
6699
6731
|
|
|
6700
6732
|
/**
|
|
6701
6733
|
* @license
|