Skip to content

Commit 45ece4c

Browse files
ADjenkovADjenkov
ADjenkov
authored and
ADjenkov
committed
refactor(outlet): introduce isNSEmptyOutlet property
1 parent 7433d9d commit 45ece4c

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Diff for: nativescript-angular/router/ns-location-strategy.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class Outlet {
2525
path: string;
2626
pathByOutlets: string;
2727
states: Array<LocationState> = [];
28+
isNSEmptyOutlet: boolean;
2829

2930
// Used in reuse-strategy by its children to determine if they should be detached too.
3031
shouldDetach: boolean = true;
@@ -41,10 +42,6 @@ export class Outlet {
4142
return this.frames.indexOf(frame) > -1;
4243
}
4344

44-
isNSEmptyOutlet(): boolean {
45-
return this.frames.length > 1;
46-
}
47-
4845
peekState(): LocationState {
4946
if (this.states.length > 0) {
5047
return this.states[this.states.length - 1];

Diff for: nativescript-angular/router/page-router-outlet.ts

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
280280
return;
281281
}
282282

283+
this.outlet.isNSEmptyOutlet = this.isEmptyOutlet;
283284
this.locationStrategy.updateOutletFrame(this.outlet, this.frame);
284285

285286
if (this.outlet && this.outlet.isPageNavigationBack) {

Diff for: nativescript-angular/router/router-extensions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class RouterExtensions {
9696
let relativeRoute = options.relativeTo || rootRoute;
9797

9898
const relativeRouteOutlet = this.findOutletByRoute(relativeRoute);
99-
const isNSEmptyOutlet = relativeRouteOutlet && relativeRouteOutlet.isNSEmptyOutlet();
99+
const isNSEmptyOutlet = relativeRouteOutlet && relativeRouteOutlet.isNSEmptyOutlet;
100100

101101
// Lazy named outlet has added 'primary' inner NSEmptyOutlet child.
102102
// Take parent route when `relativeTo` option points to the outer named outlet.
@@ -110,7 +110,7 @@ export class RouterExtensions {
110110
for (let index = 0; index < routesToMatch.length; index++) {
111111
const currentRoute = routesToMatch[index];
112112
if (outlets.some(currentOutlet => currentOutlet === currentRoute.outlet)) {
113-
let outlet = this.findOutletByRoute(currentRoute);
113+
const outlet = this.findOutletByRoute(currentRoute);
114114

115115
if (outlet) {
116116
outletsToBack.push(outlet);

0 commit comments

Comments
 (0)