fix(router): Added pushState fallback for IE 9 browser.
Closes #6506 Closes #7929
This commit is contained in:
parent
5e12a95789
commit
bab6023eee
|
@ -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 {
|
||||||
|
if(supportsState()) {
|
||||||
this._history.pushState(state, title, url);
|
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 {
|
||||||
|
if(supportsState()) {
|
||||||
this._history.replaceState(state, title, url);
|
this._history.replaceState(state, title, url);
|
||||||
|
} else {
|
||||||
|
this._location.hash = url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forward(): void { this._history.forward(); }
|
forward(): void { this._history.forward(); }
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import 'dart:html' show History;
|
||||||
|
|
||||||
|
bool supportsState() => History.supportsState;
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function supportsState(): boolean {
|
||||||
|
return !!window.history.pushState;
|
||||||
|
}
|
Loading…
Reference in New Issue