From 091a504377782b9338a9d7916f84fb18c5bbdcc2 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 6 Dec 2018 08:27:25 -0800 Subject: [PATCH] Revert "fix(router): change processing url tree children condition (#26243)" (#27516) This reverts commit ccc77ca441ae11d2b516806b4b1c1b7b3062b896. Breaks Pantheon see cl/224256517. PR Close #27516 --- packages/router/src/create_url_tree.ts | 9 +++------ packages/router/test/create_url_tree.spec.ts | 10 ++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/packages/router/src/create_url_tree.ts b/packages/router/src/create_url_tree.ts index 871fb4f0dc..c454af5099 100644 --- a/packages/router/src/create_url_tree.ts +++ b/packages/router/src/create_url_tree.ts @@ -147,17 +147,14 @@ function findStartingPosition(nav: Navigation, tree: UrlTree, route: ActivatedRo return new Position(tree.root, true, 0); } - const segmentGroup = route.snapshot._urlSegment; - if (route.snapshot._lastPathIndex === -1) { - // Pathless ActivatedRoute has _lastPathIndex === -1 but should not process children - // see issue #26224 - return new Position(segmentGroup, segmentGroup.segments.length === 0, 0); + return new Position(route.snapshot._urlSegment, true, 0); } const modifier = isMatrixParams(nav.commands[0]) ? 0 : 1; const index = route.snapshot._lastPathIndex + modifier; - return createPositionApplyingDoubleDots(segmentGroup, index, nav.numberOfDoubleDots); + return createPositionApplyingDoubleDots( + route.snapshot._urlSegment, index, nav.numberOfDoubleDots); } function createPositionApplyingDoubleDots( diff --git a/packages/router/test/create_url_tree.spec.ts b/packages/router/test/create_url_tree.spec.ts index 487d65deea..6b0e40a48e 100644 --- a/packages/router/test/create_url_tree.spec.ts +++ b/packages/router/test/create_url_tree.spec.ts @@ -233,12 +233,6 @@ describe('createUrlTree', () => { const t = create(p.root.children[PRIMARY_OUTLET], 1, p, [{outlets: {right: ['c']}}]); expect(serializer.serialize(t)).toEqual('/a/b/(right:c)'); }); - - it('should support pathless route', () => { - const p = serializer.parse('/a'); - const t = create(p.root.children[PRIMARY_OUTLET], -1, p, ['b']); - expect(serializer.serialize(t)).toEqual('/b'); - }); }); it('should set fragment', () => { @@ -266,8 +260,8 @@ function create( expect(segment).toBeDefined(); } const s = new (ActivatedRouteSnapshot as any)( - segment.segments, {}, {}, '', {}, PRIMARY_OUTLET, 'someComponent', null, - segment, startIndex, null); + [], {}, {}, '', {}, PRIMARY_OUTLET, 'someComponent', null, segment, + startIndex, null); const a = new (ActivatedRoute as any)( new BehaviorSubject(null !), new BehaviorSubject(null !), new BehaviorSubject(null !), new BehaviorSubject(null !), new BehaviorSubject(null !), PRIMARY_OUTLET, 'someComponent', s);