Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7b739c9

Browse files
committedMay 14, 2012
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
1 parent c1533ef commit 7b739c9

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed
 

‎src/ng/sniffer.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
*/
1515
function $SnifferProvider() {
1616
this.$get = ['$window', function($window) {
17-
var eventSupport = {};
17+
var eventSupport = {},
18+
android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]);
1819

1920
return {
20-
history: !!($window.history && $window.history.pushState),
21+
// Android has history.pushState, but it does not update location correctly
22+
// so let's not use the history API at all.
23+
// http://code.google.com/p/android/issues/detail?id=17471
24+
// https://github.com/angular/angular.js/issues/904
25+
history: !!($window.history && $window.history.pushState && !(android < 4)),
2126
hashchange: 'onhashchange' in $window &&
2227
// IE8 compatible mode lies
2328
(!$window.document.documentMode || $window.document.documentMode > 7),

‎test/ng/anchorScrollSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ describe('$anchorScroll', function() {
5151
elmSpy = {};
5252
$provide.value('$window', {
5353
scrollTo: jasmine.createSpy('$window.scrollTo'),
54-
document: document
54+
document: document,
55+
navigator: {}
5556
});
5657
}));
5758

‎test/ng/logSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('$log', function() {
66

77

88
beforeEach(module(function($provide){
9-
$window = {};
9+
$window = {navigator: {}};
1010
logger = '';
1111
log = function() { logger+= 'log;'; };
1212
warn = function() { logger+= 'warn;'; };

‎test/ng/snifferSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
describe('$sniffer', function() {
44

55
function sniffer($window) {
6+
$window.navigator = {};
67
return new $SnifferProvider().$get[1]($window);
78
}
89

0 commit comments

Comments
 (0)