Skip to content

Commit

Permalink
fix(nav): view.id is not overridden
Browse files Browse the repository at this point in the history
fixes #8794
  • Loading branch information
manucorporat committed Oct 20, 2016
1 parent 780717e commit 8b65398
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

This comment has been minimized.

Copy link
@trakhimenok

trakhimenok Oct 21, 2016

Should not the increment be inside if - if we don't use it why increment?

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);
Expand Down
9 changes: 9 additions & 0 deletions src/navigation/test/nav-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b65398

Please sign in to comment.