Skip to content

Commit 37f9aa4

Browse files
ADjenkovADjenkov
ADjenkov
authored and
ADjenkov
committed
chore(location-strategy): revert replaceState method
1 parent 7049dfb commit 37f9aa4

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

Diff for: e2e/nested-router-tab-view/app/home/home.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, ViewContainerRef } from "@angular/core";
22
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
33
import { RouterExtensions } from "nativescript-angular/router";
44
import { ActivatedRoute } from "@angular/router";
5-
import { confirm } from "ui/dialogs";
5+
import { confirm } from "tns-core-modules/ui/dialogs";
66

77
@Component({
88
moduleId: module.id,

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

+1-16
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ export interface LocationState {
5858

5959
@Injectable()
6060
export class NSLocationStrategy extends LocationStrategy {
61+
private outlets: Array<Outlet> = [];
6162
private currentOutlet: Outlet;
6263

6364
private popStateCallbacks = new Array<(_: any) => any>();
6465
private _currentNavigationOptions: NavigationOptions;
6566
private currentUrlTree: UrlTree;
6667

67-
public outlets: Array<Outlet> = [];
6868
public _modalNavigationDepth = 0;
6969

7070
constructor(private frameService: FrameService) {
@@ -178,21 +178,6 @@ export class NSLocationStrategy extends LocationStrategy {
178178
routerLog("NSLocationStrategy.replaceState changing existing state: " +
179179
`${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
180180
}
181-
182-
const tree = this.currentUrlTree;
183-
184-
if (url !== tree.toString()) {
185-
const urlSerializer = new DefaultUrlSerializer();
186-
const stateUrlTree: UrlTree = urlSerializer.parse(url);
187-
const rootOutlets = stateUrlTree.root.children;
188-
189-
Object.keys(rootOutlets).forEach(outletName => {
190-
const outlet = this.findOutletByKey(outletName);
191-
const topState = outlet.peekState();
192-
193-
topState.segmentGroup = rootOutlets[outletName];
194-
});
195-
}
196181
} else {
197182
if (isLogEnabled()) {
198183
routerLog("NSLocationStrategy.replaceState pushing new state: " +

Diff for: tests/app/tests/modal-dialog.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("modal-dialog", () => {
9898
let parentView = fixture.componentRef.instance.vcRef.element.nativeElement;
9999
parentView = parentView.page && parentView.page.frame;
100100
outlet.frame = parentView;
101-
locStrategy.outlets.push(outlet);
101+
locStrategy._getOutlets().push(outlet);
102102

103103
locStrategy.pushState(null, "test", "/test", null);
104104

@@ -120,7 +120,7 @@ describe("modal-dialog", () => {
120120
let parentView = fixture.componentRef.instance.vcRef.element.nativeElement;
121121
parentView = parentView.page && parentView.page.frame;
122122
outlet.frame = parentView;
123-
locStrategy.outlets.push(outlet);
123+
locStrategy._getOutlets().push(outlet);
124124

125125
locStrategy.pushState(null, "test", "/test", null);
126126

Diff for: tests/app/tests/ns-location-strategy.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ describe("NSLocationStrategy", () => {
242242
assert.equal(strategy.path(), "/test");
243243

244244
strategy.replaceState(null, "test2", "/test2", null);
245-
assert.equal(strategy.path(), "/test2");
245+
// Currently replaceState does nothing since this shouldn't affect any functionality on {N} side.
246+
// replaceState should be relevant only in Web.
247+
// assert.equal(strategy.path(), "/test2");
246248

247249
assert.equal(popCount, 0); // no onPopState when replacing
248250
});
@@ -258,7 +260,9 @@ describe("NSLocationStrategy", () => {
258260
assert.equal(strategy.path(), "/(test1:test12//test2:test2)");
259261

260262
strategy.replaceState(null, "test2", "/(test1:test13//test2:test2)", null);
261-
assert.equal(strategy.path(), "/(test1:test13//test2:test2)");
263+
// Currently replaceState does nothing since this shouldn't affect any functionality on {N} side.
264+
// replaceState should be relevant only in Web.
265+
// assert.equal(strategy.path(), "/(test1:test13//test2:test2)");
262266

263267
assert.equal(popCount, 0); // no onPopState when replacing
264268
});

0 commit comments

Comments
 (0)