diff --git a/modules/@angular/common/src/location/hash_location_strategy.ts b/modules/@angular/common/src/location/hash_location_strategy.ts index 5a0b81c204..5dd2834c49 100644 --- a/modules/@angular/common/src/location/hash_location_strategy.ts +++ b/modules/@angular/common/src/location/hash_location_strategy.ts @@ -12,7 +12,7 @@ import {isPresent} from '../facade/lang'; import {Location} from './location'; import {APP_BASE_HREF, LocationStrategy} from './location_strategy'; -import {PlatformLocation, UrlChangeListener} from './platform_location'; +import {LocationChangeListener, PlatformLocation} from './platform_location'; @@ -54,7 +54,7 @@ export class HashLocationStrategy extends LocationStrategy { } } - onPopState(fn: UrlChangeListener): void { + onPopState(fn: LocationChangeListener): void { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); } diff --git a/modules/@angular/common/src/location/location_strategy.ts b/modules/@angular/common/src/location/location_strategy.ts index 9ec9f084fa..97ba81885c 100644 --- a/modules/@angular/common/src/location/location_strategy.ts +++ b/modules/@angular/common/src/location/location_strategy.ts @@ -7,7 +7,7 @@ */ import {OpaqueToken} from '@angular/core'; -import {UrlChangeListener} from './platform_location'; +import {LocationChangeListener} from './platform_location'; /** * `LocationStrategy` is responsible for representing and reading route state @@ -34,7 +34,7 @@ export abstract class LocationStrategy { abstract replaceState(state: any, title: string, url: string, queryParams: string): void; abstract forward(): void; abstract back(): void; - abstract onPopState(fn: UrlChangeListener): void; + abstract onPopState(fn: LocationChangeListener): void; abstract getBaseHref(): string; } diff --git a/modules/@angular/common/src/location/path_location_strategy.ts b/modules/@angular/common/src/location/path_location_strategy.ts index e151967b50..54fbdbc2a8 100644 --- a/modules/@angular/common/src/location/path_location_strategy.ts +++ b/modules/@angular/common/src/location/path_location_strategy.ts @@ -12,7 +12,8 @@ import {isBlank} from '../facade/lang'; import {Location} from './location'; import {APP_BASE_HREF, LocationStrategy} from './location_strategy'; -import {PlatformLocation, UrlChangeListener} from './platform_location'; +import {LocationChangeListener, PlatformLocation} from './platform_location'; + /** @@ -59,7 +60,7 @@ export class PathLocationStrategy extends LocationStrategy { this._baseHref = href; } - onPopState(fn: UrlChangeListener): void { + onPopState(fn: LocationChangeListener): void { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); } diff --git a/modules/@angular/common/src/location/platform_location.ts b/modules/@angular/common/src/location/platform_location.ts index adad468253..4983c96fe5 100644 --- a/modules/@angular/common/src/location/platform_location.ts +++ b/modules/@angular/common/src/location/platform_location.ts @@ -34,8 +34,8 @@ */ export abstract class PlatformLocation { abstract getBaseHrefFromDOM(): string; - abstract onPopState(fn: UrlChangeListener): void; - abstract onHashChange(fn: UrlChangeListener): void; + abstract onPopState(fn: LocationChangeListener): void; + abstract onHashChange(fn: LocationChangeListener): void; get pathname(): string { return null; } get search(): string { return null; } @@ -55,9 +55,9 @@ export abstract class PlatformLocation { * * @experimental */ -export interface UrlChangeEvent { type: string; } +export interface LocationChangeEvent { type: string; } /** * @experimental */ -export interface UrlChangeListener { (e: UrlChangeEvent): any; } +export interface LocationChangeListener { (e: LocationChangeEvent): any; } diff --git a/modules/@angular/platform-browser/src/browser/location/browser_platform_location.ts b/modules/@angular/platform-browser/src/browser/location/browser_platform_location.ts index 813d9e199a..62ecd061ca 100644 --- a/modules/@angular/platform-browser/src/browser/location/browser_platform_location.ts +++ b/modules/@angular/platform-browser/src/browser/location/browser_platform_location.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {PlatformLocation, UrlChangeListener} from '@angular/common'; +import {LocationChangeListener, PlatformLocation} from '@angular/common'; import {Injectable} from '@angular/core'; import {getDOM} from '../../dom/dom_adapter'; @@ -45,11 +45,11 @@ export class BrowserPlatformLocation extends PlatformLocation { getBaseHrefFromDOM(): string { return getDOM().getBaseHref(); } - onPopState(fn: UrlChangeListener): void { + onPopState(fn: LocationChangeListener): void { getDOM().getGlobalEventTarget('window').addEventListener('popstate', fn, false); } - onHashChange(fn: UrlChangeListener): void { + onHashChange(fn: LocationChangeListener): void { getDOM().getGlobalEventTarget('window').addEventListener('hashchange', fn, false); } diff --git a/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts b/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts index 9c39603099..e9abf43ca0 100644 --- a/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts +++ b/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {UrlChangeListener} from '@angular/common'; +import {LocationChangeListener} from '@angular/common'; import {Injectable} from '@angular/core'; import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location'; @@ -28,9 +28,9 @@ export class MessageBasedPlatformLocation { private _platformLocation: BrowserPlatformLocation, bus: MessageBus, private _serializer: Serializer) { this._platformLocation.onPopState( - FunctionWrapper.bind(this._sendUrlChangeEvent, this)); + FunctionWrapper.bind(this._sendUrlChangeEvent, this)); this._platformLocation.onHashChange( - FunctionWrapper.bind(this._sendUrlChangeEvent, this)); + FunctionWrapper.bind(this._sendUrlChangeEvent, this)); this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL); this._channelSink = bus.to(ROUTER_CHANNEL); } diff --git a/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts b/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts index f953b269e9..204b026c37 100644 --- a/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts +++ b/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {PlatformLocation, UrlChangeListener} from '@angular/common'; +import {LocationChangeListener, PlatformLocation} from '@angular/common'; import {BaseException, Injectable} from '@angular/core'; import {EventEmitter} from '../../facade/async'; @@ -75,9 +75,9 @@ export class WebWorkerPlatformLocation extends PlatformLocation { 'Attempt to get base href from DOM from WebWorker. You must either provide a value for the APP_BASE_HREF token through DI or use the hash location strategy.'); } - onPopState(fn: UrlChangeListener): void { this._popStateListeners.push(fn); } + onPopState(fn: LocationChangeListener): void { this._popStateListeners.push(fn); } - onHashChange(fn: UrlChangeListener): void { this._hashChangeListeners.push(fn); } + onHashChange(fn: LocationChangeListener): void { this._hashChangeListeners.push(fn); } get pathname(): string { if (this._location === null) { diff --git a/tools/public_api_guard/common/index.d.ts b/tools/public_api_guard/common/index.d.ts index 5d689651fd..ceae67d981 100644 --- a/tools/public_api_guard/common/index.d.ts +++ b/tools/public_api_guard/common/index.d.ts @@ -33,7 +33,7 @@ export declare class HashLocationStrategy extends LocationStrategy { back(): void; forward(): void; getBaseHref(): string; - onPopState(fn: UrlChangeListener): void; + onPopState(fn: LocationChangeListener): void; path(includeHash?: boolean): string; prepareExternalUrl(internal: string): string; pushState(state: any, title: string, path: string, queryParams: string): void; @@ -77,12 +77,22 @@ export declare class Location { static stripTrailingSlash(url: string): string; } +/** @experimental */ +export interface LocationChangeEvent { + type: string; +} + +/** @experimental */ +export interface LocationChangeListener { + (e: LocationChangeEvent): any; +} + /** @stable */ export declare abstract class LocationStrategy { abstract back(): void; abstract forward(): void; abstract getBaseHref(): string; - abstract onPopState(fn: UrlChangeListener): void; + abstract onPopState(fn: LocationChangeListener): void; abstract path(includeHash?: boolean): string; abstract prepareExternalUrl(internal: string): string; abstract pushState(state: any, title: string, url: string, queryParams: string): void; @@ -177,7 +187,7 @@ export declare class PathLocationStrategy extends LocationStrategy { back(): void; forward(): void; getBaseHref(): string; - onPopState(fn: UrlChangeListener): void; + onPopState(fn: LocationChangeListener): void; path(includeHash?: boolean): string; prepareExternalUrl(internal: string): string; pushState(state: any, title: string, url: string, queryParams: string): void; @@ -197,8 +207,8 @@ export declare abstract class PlatformLocation { abstract back(): void; abstract forward(): void; abstract getBaseHrefFromDOM(): string; - abstract onHashChange(fn: UrlChangeListener): void; - abstract onPopState(fn: UrlChangeListener): void; + abstract onHashChange(fn: LocationChangeListener): void; + abstract onPopState(fn: LocationChangeListener): void; abstract pushState(state: any, title: string, url: string): void; abstract replaceState(state: any, title: string, url: string): void; } @@ -212,13 +222,3 @@ export declare class SlicePipe implements PipeTransform { export declare class UpperCasePipe implements PipeTransform { transform(value: string): string; } - -/** @experimental */ -export interface UrlChangeEvent { - type: string; -} - -/** @experimental */ -export interface UrlChangeListener { - (e: UrlChangeEvent): any; -} diff --git a/tools/public_api_guard/platform-browser/index.d.ts b/tools/public_api_guard/platform-browser/index.d.ts index 5d881b88fb..cd5ef2b80f 100644 --- a/tools/public_api_guard/platform-browser/index.d.ts +++ b/tools/public_api_guard/platform-browser/index.d.ts @@ -21,8 +21,8 @@ export declare class BrowserPlatformLocation extends PlatformLocation { back(): void; forward(): void; getBaseHrefFromDOM(): string; - onHashChange(fn: UrlChangeListener): void; - onPopState(fn: UrlChangeListener): void; + onHashChange(fn: LocationChangeListener): void; + onPopState(fn: LocationChangeListener): void; pushState(state: any, title: string, url: string): void; replaceState(state: any, title: string, url: string): void; }