fix(aio): AppComponent should scroll only once when location changes
This commit is contained in:

committed by
Pete Bacon Darwin

parent
710b4a3503
commit
ac5e6baced
@ -2,7 +2,8 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
|
||||
export class MockLocationService {
|
||||
urlSubject = new BehaviorSubject<string>(this.initialUrl);
|
||||
currentUrl = this.urlSubject.asObservable();
|
||||
currentUrl = this.urlSubject.asObservable().map(url => this.stripSlashes(url));
|
||||
// strip off query and hash
|
||||
currentPath = this.currentUrl.map(url => url.match(/[^?#]*/)[0]);
|
||||
search = jasmine.createSpy('search').and.returnValue({});
|
||||
setSearch = jasmine.createSpy('setSearch');
|
||||
@ -12,5 +13,9 @@ export class MockLocationService {
|
||||
.and.returnValue(false); // prevent click from causing a browser navigation
|
||||
|
||||
constructor(private initialUrl) {}
|
||||
|
||||
private stripSlashes(url: string) {
|
||||
return url.replace(/^\/+/, '').replace(/\/+(\?|#|$)/, '$1');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user