fix(router): Added pushState fallback for IE 9 browser.

Closes #6506

Closes #7929
This commit is contained in:
Vanga Sasidhar 2016-04-06 21:38:43 +05:30 committed by Misko Hevery
parent 5e12a95789
commit bab6023eee
3 changed files with 17 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import {Injectable} from '@angular/core';
import {History, Location} from '../../../src/facade/browser'; import {History, Location} from '../../../src/facade/browser';
import {UrlChangeListener, PlatformLocation} from '@angular/common'; import {UrlChangeListener, PlatformLocation} from '@angular/common';
import {getDOM} from '../../dom/dom_adapter'; 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; } set pathname(newPath: string) { this._location.pathname = newPath; }
pushState(state: any, title: string, url: string): void { 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 { 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(); } forward(): void { this._history.forward(); }

View File

@ -0,0 +1,3 @@
import 'dart:html' show History;
bool supportsState() => History.supportsState;

View File

@ -0,0 +1,3 @@
export function supportsState(): boolean {
return !!window.history.pushState;
}