| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0f1b370 commit 76d6f5f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,10 +59,12 @@ export class Router { | |||
| 59 | 59 | .then(currTree => { | |
| 60 | 60 | return new _LoadSegments(currTree, this._prevTree) | |
| 61 | 61 | .load(this._routerOutletMap, this._rootComponent) | |
| 62 | - .then(_ => { | ||
| 63 | - this._prevTree = currTree; | ||
| 64 | - this._location.go(this._urlSerializer.serialize(this._urlTree)); | ||
| 65 | - this._changes.emit(null); | ||
| 62 | + .then(updated => { | ||
| 63 | + if (updated) { | ||
| 64 | + this._prevTree = currTree; | ||
| 65 | + this._location.go(this._urlSerializer.serialize(this._urlTree)); | ||
| 66 | + this._changes.emit(null); | ||
| 67 | + } | ||
| 66 | 68 | }); | |
| 67 | 69 | }); | |
| 68 | 70 | } | |
@@ -90,7 +92,7 @@ class _LoadSegments { | |||
| 90 | 92 | ||
| 91 | 93 | constructor(private currTree: Tree<RouteSegment>, private prevTree: Tree<RouteSegment>) {} | |
| 92 | 94 | ||
| 93 | - load(parentOutletMap: RouterOutletMap, rootComponent: Object): Promise<void> { | ||
| 95 | + load(parentOutletMap: RouterOutletMap, rootComponent: Object): Promise<boolean> { | ||
| 94 | 96 | let prevRoot = isPresent(this.prevTree) ? rootNode(this.prevTree) : null; | |
| 95 | 97 | let currRoot = rootNode(this.currTree); | |
| 96 | 98 | ||
@@ -100,6 +102,7 @@ class _LoadSegments { | |||
| 100 | 102 | if (res) { | |
| 101 | 103 | this.loadChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]); | |
| 102 | 104 | } | |
| 105 | + return res; | ||
| 103 | 106 | }); | |
| 104 | 107 | } | |
| 105 | 108 | ||
@@ -189,7 +192,7 @@ class _LoadSegments { | |||
| 189 | 192 | } | |
| 190 | 193 | ||
| 191 | 194 | private unloadOutlet(outlet: RouterOutlet, components: Object[]): void { | |
| 192 | - if (outlet.isLoaded) { | ||
| 195 | + if (isPresent(outlet) && outlet.isLoaded) { | ||
| 193 | 196 | StringMapWrapper.forEach(outlet.outletMap._outlets, | |
| 194 | 197 | (v, k) => this.unloadOutlet(v, components)); | |
| 195 | 198 | if (this.performMutation) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,7 +127,7 @@ export function main() { | |||
| 127 | 127 | }))); | |
| 128 | 128 | ||
| 129 | 129 | it('should not unload the route if can deactivate returns false', | |
| 130 | - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { | ||
| 130 | + fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { | ||
| 131 | 131 | let fixture = tcb.createFakeAsync(RootCmp); | |
| 132 | 132 | ||
| 133 | 133 | router.navigateByUrl('/team/22/cannotDeactivate'); | |
@@ -138,6 +138,8 @@ export function main() { | |||
| 138 | 138 | ||
| 139 | 139 | expect(fixture.debugElement.nativeElement) | |
| 140 | 140 | .toHaveText('team 22 { cannotDeactivate, aux: }'); | |
| 141 | + | ||
| 142 | + expect(location.path()).toEqual('/team/22/cannotDeactivate'); | ||
| 141 | 143 | }))); | |
| 142 | 144 | ||
| 143 | 145 | if (DOM.supportsDOMEvents()) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments