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

Commit

Permalink
fix($sniffer): report history false on Android < 4
Browse files Browse the repository at this point in the history
Android has history.pushState, but it does not update the location correctly:
http://code.google.com/p/android/issues/detail?id=17471

Closes #904
  • Loading branch information
vojtajina committed May 14, 2012
1 parent c1533ef commit 7b739c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/ng/sniffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
*/
function $SnifferProvider() {
this.$get = ['$window', function($window) {
var eventSupport = {};
var eventSupport = {},
android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]);

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 &&
// IE8 compatible mode lies
(!$window.document.documentMode || $window.document.documentMode > 7),
Expand Down
3 changes: 2 additions & 1 deletion test/ng/anchorScrollSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ describe('$anchorScroll', function() {
elmSpy = {};
$provide.value('$window', {
scrollTo: jasmine.createSpy('$window.scrollTo'),
document: document
document: document,
navigator: {}
});
}));

Expand Down
2 changes: 1 addition & 1 deletion test/ng/logSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('$log', function() {


beforeEach(module(function($provide){
$window = {};
$window = {navigator: {}};
logger = '';
log = function() { logger+= 'log;'; };
warn = function() { logger+= 'warn;'; };
Expand Down
1 change: 1 addition & 0 deletions test/ng/snifferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe('$sniffer', function() {

function sniffer($window) {
$window.navigator = {};
return new $SnifferProvider().$get[1]($window);
}

Expand Down

0 comments on commit 7b739c9

Please sign in to comment.