From bab6023eee1d34a8b27c28cd44af3c9096b167cd Mon Sep 17 00:00:00 2001 From: Vanga Sasidhar Date: Wed, 6 Apr 2016 21:38:43 +0530 Subject: [PATCH] fix(router): Added pushState fallback for IE 9 browser. Closes #6506 Closes #7929 --- .../browser/location/browser_platform_location.ts | 14 +++++++++++--- .../src/browser/location/history.dart | 3 +++ .../src/browser/location/history.ts | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 modules/@angular/platform-browser/src/browser/location/history.dart create mode 100644 modules/@angular/platform-browser/src/browser/location/history.ts 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 7c89bcc5e0..1f74bdb949 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 @@ -2,7 +2,7 @@ import {Injectable} from '@angular/core'; import {History, Location} from '../../../src/facade/browser'; import {UrlChangeListener, PlatformLocation} from '@angular/common'; import {getDOM} from '../../dom/dom_adapter'; - +import {supportsState} from './history'; /** @@ -46,11 +46,19 @@ export class BrowserPlatformLocation extends PlatformLocation { set pathname(newPath: string) { this._location.pathname = newPath; } pushState(state: any, title: string, url: string): void { - this._history.pushState(state, title, url); + if(supportsState()) { + this._history.pushState(state, title, url); + } else { + this._location.hash = url; + } } replaceState(state: any, title: string, url: string): void { - this._history.replaceState(state, title, url); + if(supportsState()) { + this._history.replaceState(state, title, url); + } else { + this._location.hash = url; + } } forward(): void { this._history.forward(); } diff --git a/modules/@angular/platform-browser/src/browser/location/history.dart b/modules/@angular/platform-browser/src/browser/location/history.dart new file mode 100644 index 0000000000..1a06ea9ff6 --- /dev/null +++ b/modules/@angular/platform-browser/src/browser/location/history.dart @@ -0,0 +1,3 @@ +import 'dart:html' show History; + +bool supportsState() => History.supportsState; \ No newline at end of file diff --git a/modules/@angular/platform-browser/src/browser/location/history.ts b/modules/@angular/platform-browser/src/browser/location/history.ts new file mode 100644 index 0000000000..92104a3c94 --- /dev/null +++ b/modules/@angular/platform-browser/src/browser/location/history.ts @@ -0,0 +1,3 @@ +export function supportsState(): boolean { + return !!window.history.pushState; +} \ No newline at end of file