mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-15 02:03:11 +00:00
fix($sniffer): report history false on Android < 4
Android has history.pushState, but it does not update the location correctly: http://code.google.com/p/android/issues/detail?id=17471 Closes #904
This commit is contained in:
parent
c1533ef576
commit
7b739c9702
4 changed files with 11 additions and 4 deletions
|
|
@ -14,10 +14,15 @@
|
||||||
*/
|
*/
|
||||||
function $SnifferProvider() {
|
function $SnifferProvider() {
|
||||||
this.$get = ['$window', function($window) {
|
this.$get = ['$window', function($window) {
|
||||||
var eventSupport = {};
|
var eventSupport = {},
|
||||||
|
android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
history: !!($window.history && $window.history.pushState),
|
// Android has history.pushState, but it does not update location correctly
|
||||||
|
// so let's not use the history API at all.
|
||||||
|
// http://code.google.com/p/android/issues/detail?id=17471
|
||||||
|
// https://github.com/angular/angular.js/issues/904
|
||||||
|
history: !!($window.history && $window.history.pushState && !(android < 4)),
|
||||||
hashchange: 'onhashchange' in $window &&
|
hashchange: 'onhashchange' in $window &&
|
||||||
// IE8 compatible mode lies
|
// IE8 compatible mode lies
|
||||||
(!$window.document.documentMode || $window.document.documentMode > 7),
|
(!$window.document.documentMode || $window.document.documentMode > 7),
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ describe('$anchorScroll', function() {
|
||||||
elmSpy = {};
|
elmSpy = {};
|
||||||
$provide.value('$window', {
|
$provide.value('$window', {
|
||||||
scrollTo: jasmine.createSpy('$window.scrollTo'),
|
scrollTo: jasmine.createSpy('$window.scrollTo'),
|
||||||
document: document
|
document: document,
|
||||||
|
navigator: {}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ describe('$log', function() {
|
||||||
|
|
||||||
|
|
||||||
beforeEach(module(function($provide){
|
beforeEach(module(function($provide){
|
||||||
$window = {};
|
$window = {navigator: {}};
|
||||||
logger = '';
|
logger = '';
|
||||||
log = function() { logger+= 'log;'; };
|
log = function() { logger+= 'log;'; };
|
||||||
warn = function() { logger+= 'warn;'; };
|
warn = function() { logger+= 'warn;'; };
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
describe('$sniffer', function() {
|
describe('$sniffer', function() {
|
||||||
|
|
||||||
function sniffer($window) {
|
function sniffer($window) {
|
||||||
|
$window.navigator = {};
|
||||||
return new $SnifferProvider().$get[1]($window);
|
return new $SnifferProvider().$get[1]($window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue