Skip to content

Commit 2308239

Browse files
committed
fix(angular): proxies
1 parent cece447 commit 2308239

File tree

7 files changed

+276
-74
lines changed

7 files changed

+276
-74
lines changed

angular/src/directives/proxies-list.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const DIRECTIVES = [
4141
d.Menu,
4242
d.MenuButton,
4343
d.MenuToggle,
44-
d.NavControllerBase,
44+
d.Nav,
4545
d.NavPop,
4646
d.NavPush,
4747
d.NavSetRoot,

angular/src/directives/proxies.ts

+253-42
Large diffs are not rendered by default.

angular/src/module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const DECLARATIONS = [
4747
d.Menu,
4848
d.MenuButton,
4949
d.MenuToggle,
50-
d.NavControllerBase,
50+
d.Nav,
5151
d.NavPop,
5252
d.NavPush,
5353
d.NavSetRoot,

angular/test/nav/.angular-cli.json

+3
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,8 @@
6161
"defaults": {
6262
"styleExt": "scss",
6363
"component": {}
64+
},
65+
"warnings": {
66+
"typescriptMismatch": false
6467
}
6568
}

core/src/components/nav/nav.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import mdTransitionAnimation from './animations/md.transition';
2323
@Component({
2424
tag: 'ion-nav',
2525
})
26-
export class NavControllerBase implements NavOutlet {
26+
export class Nav implements NavOutlet {
2727

2828
private _init = false;
2929
private _queue: TransitionInstruction[] = [];
@@ -470,7 +470,7 @@ export class NavControllerBase implements NavOutlet {
470470
for (let i = 0; i < viewControllers.length; i++) {
471471
const view = viewControllers[i];
472472
view.delegate = ti.opts.delegate;
473-
const nav = view._nav;
473+
const nav = view.nav;
474474
if (nav && nav !== this) {
475475
throw new Error('inserted view was already inserted');
476476
}
@@ -663,13 +663,13 @@ export class NavControllerBase implements NavOutlet {
663663
if (existingIndex > -1) {
664664
// this view is already in the stack!!
665665
// move it to its new location
666-
assert(view._nav === this, 'view is not part of the nav');
666+
assert(view.nav === this, 'view is not part of the nav');
667667
this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]);
668668
} else {
669-
assert(!view._nav, 'nav is used');
669+
assert(!view.nav, 'nav is used');
670670
// this is a new view to add to the stack
671671
// create the new entering view
672-
view._setNav(this);
672+
view.nav = this;
673673

674674
// insert the entering view into the correct index in the stack
675675
this._views.splice(index, 0, view);

core/src/components/nav/test/nav-controller.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mockDocument, mockElement } from '@stencil/core/testing';
2-
import { NavControllerBase } from '../nav';
2+
import { Nav } from '../nav';
33
import { ViewController } from '../view-controller';
44
import { AnimationControllerImpl } from '../../animation-controller/animation-controller';
55
import { createConfigController } from '../../../global/config-controller';
@@ -345,8 +345,8 @@ describe('NavController', () => {
345345
expect(nav.getByIndex(3).component).toEqual(MockView2);
346346
expect(nav.getByIndex(4).component).toEqual(MockView3);
347347

348-
expect(nav.getByIndex(1)._nav).toEqual(nav);
349-
expect(nav.getByIndex(2)._nav).toEqual(nav);
348+
expect(nav.getByIndex(1).nav).toEqual(nav);
349+
expect(nav.getByIndex(2).nav).toEqual(nav);
350350

351351
}, 10000);
352352
});
@@ -357,7 +357,7 @@ describe('NavController', () => {
357357
nav.pop(null, trnsDone).then(() => {
358358
fail('it should not succeed');
359359
done();
360-
}).catch((err) => {
360+
}).catch((err: any) => {
361361
const hasCompleted = false;
362362
const requiresTransition = false;
363363
const rejectReason = new Error('no views in the stack to be removed');
@@ -1019,7 +1019,7 @@ describe('NavController', () => {
10191019
});
10201020

10211021

1022-
let nav: NavControllerBase;
1022+
let nav: Nav;
10231023

10241024
function spyOnLifecycles(view: ViewController) {
10251025
const element = view.element as any;
@@ -1091,15 +1091,15 @@ function mockView(component ?: any, data ?: any) {
10911091
return view;
10921092
}
10931093

1094-
function mockViews(nav: NavControllerBase, views: ViewController[]) {
1094+
function mockViews(nav: Nav, views: ViewController[]) {
10951095
nav['_views'] = views;
10961096
views.forEach(v => {
1097-
v._setNav(nav);
1097+
v.nav = nav;
10981098
});
10991099
}
11001100

1101-
function mockNavController(): NavControllerBase {
1102-
const nav = new NavControllerBase() as any;
1101+
function mockNavController(): Nav {
1102+
const nav = new Nav() as any;
11031103
nav.el = mockElement('ion-nav') as HTMLElement;
11041104
nav.ionNavChanged = {emit: function() { return; } };
11051105
nav.animationCtrl = new AnimationControllerImpl() as any;

core/src/components/nav/view-controller.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
import { NavOptions, ViewState } from './nav-util';
3-
import { NavControllerBase } from './nav';
43
import { assert } from '../../utils/helpers';
5-
import { FrameworkDelegate } from '../..';
4+
import { FrameworkDelegate, Nav } from '../..';
65
import { attachComponent } from '../../utils/framework-delegate';
76

87
/**
@@ -27,7 +26,7 @@ export class ViewController {
2726
private _cntDir: any;
2827
private _leavingOpts: NavOptions;
2928

30-
_nav: NavControllerBase;
29+
nav: Nav;
3130
_state: ViewState = ViewState.New;
3231

3332
/** @hidden */
@@ -52,17 +51,6 @@ export class ViewController {
5251
}
5352
}
5453

55-
_setNav(navCtrl: NavControllerBase) {
56-
this._nav = navCtrl;
57-
}
58-
59-
/**
60-
* @hidden
61-
*/
62-
getNav(): NavControllerBase {
63-
return this._nav;
64-
}
65-
6654
/**
6755
* @hidden
6856
*/
@@ -115,7 +103,7 @@ export class ViewController {
115103
element.remove();
116104
}
117105
}
118-
this._nav = this._cntDir = this._leavingOpts = null;
106+
this.nav = this._cntDir = this._leavingOpts = null;
119107
this._state = ViewState.Destroyed;
120108
}
121109

@@ -124,7 +112,7 @@ export class ViewController {
124112
* @returns {number} Returns the index of this page within its `NavController`.
125113
*/
126114
get index(): number {
127-
return (this._nav ? this._nav.indexOf(this) : -1);
115+
return (this.nav ? this.nav.indexOf(this) : -1);
128116
}
129117
}
130118

0 commit comments

Comments
 (0)