From 8b65398044adbd34e24802d9f54ff2ce4b254e2a Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Thu, 20 Oct 2016 22:06:43 +0200 Subject: [PATCH] fix(nav): view.id is not overridden fixes #8794 --- src/navigation/nav-controller-base.ts | 5 ++++- src/navigation/test/nav-controller.spec.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index 510772ff085..e20f82b42e1 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -689,7 +689,10 @@ export class NavControllerBase extends Ion implements NavController { view._setNav(this); // give this inserted view an ID - view.id = this.id + '-' + (++this._ids); + this._ids++; + if (!view.id) { + view.id = `${this.id}-${this._ids}`; + } // insert the entering view into the correct index in the stack this._views.splice(index, 0, view); diff --git a/src/navigation/test/nav-controller.spec.ts b/src/navigation/test/nav-controller.spec.ts index 206e0f6cf98..59d697f6f02 100644 --- a/src/navigation/test/nav-controller.spec.ts +++ b/src/navigation/test/nav-controller.spec.ts @@ -165,6 +165,15 @@ describe('NavController', () => { describe('insert', () => { + it('should not modify the view id', () => { + let view = mockView(MockView4); + view.id = 'custom_id'; + nav.insert(0, view); + + expect(view.id).toEqual('custom_id'); + }); + + it('should insert at the begining with no async transition', () => { let view4 = mockView(MockView4); let instance4 = spyOnLifecycles(view4);