Revert: "feat(router): add navigationSource and restoredState to NavigationStart event (#21728)"
This reverts commit 3b7bab7d22
. Will be re-merged after fixing integration of minor breaking change.
This commit is contained in:
@ -19,7 +19,7 @@ import {ISubscription} from 'rxjs/Subscription';
|
||||
@Injectable()
|
||||
export class SpyLocation implements Location {
|
||||
urlChanges: string[] = [];
|
||||
private _history: LocationState[] = [new LocationState('', '', null)];
|
||||
private _history: LocationState[] = [new LocationState('', '')];
|
||||
private _historyIndex: number = 0;
|
||||
/** @internal */
|
||||
_subject: EventEmitter<any> = new EventEmitter();
|
||||
@ -34,8 +34,6 @@ export class SpyLocation implements Location {
|
||||
|
||||
path(): string { return this._history[this._historyIndex].path; }
|
||||
|
||||
private state(): string { return this._history[this._historyIndex].state; }
|
||||
|
||||
isCurrentPathEqualTo(path: string, query: string = ''): boolean {
|
||||
const givenPath = path.endsWith('/') ? path.substring(0, path.length - 1) : path;
|
||||
const currPath =
|
||||
@ -62,13 +60,13 @@ export class SpyLocation implements Location {
|
||||
return this._baseHref + url;
|
||||
}
|
||||
|
||||
go(path: string, query: string = '', state: any = null) {
|
||||
go(path: string, query: string = '') {
|
||||
path = this.prepareExternalUrl(path);
|
||||
|
||||
if (this._historyIndex > 0) {
|
||||
this._history.splice(this._historyIndex + 1);
|
||||
}
|
||||
this._history.push(new LocationState(path, query, state));
|
||||
this._history.push(new LocationState(path, query));
|
||||
this._historyIndex = this._history.length - 1;
|
||||
|
||||
const locationState = this._history[this._historyIndex - 1];
|
||||
@ -81,7 +79,7 @@ export class SpyLocation implements Location {
|
||||
this._subject.emit({'url': url, 'pop': false});
|
||||
}
|
||||
|
||||
replaceState(path: string, query: string = '', state: any = null) {
|
||||
replaceState(path: string, query: string = '') {
|
||||
path = this.prepareExternalUrl(path);
|
||||
|
||||
const history = this._history[this._historyIndex];
|
||||
@ -91,7 +89,6 @@ export class SpyLocation implements Location {
|
||||
|
||||
history.path = path;
|
||||
history.query = query;
|
||||
history.state = state;
|
||||
|
||||
const url = path + (query.length > 0 ? ('?' + query) : '');
|
||||
this.urlChanges.push('replace: ' + url);
|
||||
@ -100,14 +97,14 @@ export class SpyLocation implements Location {
|
||||
forward() {
|
||||
if (this._historyIndex < (this._history.length - 1)) {
|
||||
this._historyIndex++;
|
||||
this._subject.emit({'url': this.path(), 'state': this.state(), 'pop': true});
|
||||
this._subject.emit({'url': this.path(), 'pop': true});
|
||||
}
|
||||
}
|
||||
|
||||
back() {
|
||||
if (this._historyIndex > 0) {
|
||||
this._historyIndex--;
|
||||
this._subject.emit({'url': this.path(), 'state': this.state(), 'pop': true});
|
||||
this._subject.emit({'url': this.path(), 'pop': true});
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,5 +118,10 @@ export class SpyLocation implements Location {
|
||||
}
|
||||
|
||||
class LocationState {
|
||||
constructor(public path: string, public query: string, public state: any) {}
|
||||
path: string;
|
||||
query: string;
|
||||
constructor(path: string, query: string) {
|
||||
this.path = path;
|
||||
this.query = query;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user