mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-04 05:04:44 +00:00
fix($sniffer): history problems on Boxee box
History API not working properly on Boxee box browser (old Webkit) problem similar to the one on Android < 4
This commit is contained in:
parent
74ae3edf86
commit
eefcdad013
2 changed files with 34 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ function $SnifferProvider() {
|
||||||
this.$get = ['$window', '$document', function($window, $document) {
|
this.$get = ['$window', '$document', function($window, $document) {
|
||||||
var eventSupport = {},
|
var eventSupport = {},
|
||||||
android = int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
|
android = int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
|
||||||
|
boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
|
||||||
document = $document[0] || {},
|
document = $document[0] || {},
|
||||||
vendorPrefix,
|
vendorPrefix,
|
||||||
vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
|
vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
|
||||||
|
|
@ -42,10 +43,10 @@ function $SnifferProvider() {
|
||||||
|
|
||||||
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
|
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
|
||||||
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
|
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
|
||||||
|
|
||||||
if (android && (!transitions||!animations)) {
|
if (android && (!transitions||!animations)) {
|
||||||
transitions = isString(document.body.style.webkitTransition);
|
transitions = isString(document.body.style.webkitTransition);
|
||||||
animations = isString(document.body.style.webkitAnimation);
|
animations = isString(document.body.style.webkitAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +56,10 @@ function $SnifferProvider() {
|
||||||
// so let's not use the history API at all.
|
// so let's not use the history API at all.
|
||||||
// http://code.google.com/p/android/issues/detail?id=17471
|
// http://code.google.com/p/android/issues/detail?id=17471
|
||||||
// https://github.com/angular/angular.js/issues/904
|
// https://github.com/angular/angular.js/issues/904
|
||||||
history: !!($window.history && $window.history.pushState && !(android < 4)),
|
|
||||||
|
// older webit browser (533.9) on Boxee box has exactly the same problem as Android has
|
||||||
|
// so let's not use the history API also
|
||||||
|
history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee),
|
||||||
hashchange: 'onhashchange' in $window &&
|
hashchange: 'onhashchange' in $window &&
|
||||||
// IE8 compatible mode lies
|
// IE8 compatible mode lies
|
||||||
(!document.documentMode || document.documentMode > 7),
|
(!document.documentMode || document.documentMode > 7),
|
||||||
|
|
|
||||||
|
|
@ -316,4 +316,30 @@ describe('$sniffer', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('history', function() {
|
||||||
|
it('should be true on Boxee box with an older version of Webkit', function() {
|
||||||
|
module(function($provide) {
|
||||||
|
var doc = {
|
||||||
|
body : {
|
||||||
|
style : {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var win = {
|
||||||
|
history: {
|
||||||
|
pushState: noop
|
||||||
|
},
|
||||||
|
navigator: {
|
||||||
|
userAgent: 'boxee (alpha/Darwin 8.7.1 i386 - 0.9.11.5591)'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$provide.value('$document', jqLite(doc));
|
||||||
|
$provide.value('$window', win);
|
||||||
|
});
|
||||||
|
inject(function($sniffer) {
|
||||||
|
expect($sniffer.history).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue