-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
history check for version of Android 4.0.x aswell #891
Conversation
According to issue 23979, this is still a problem in the Android 4.1.x native browser (Chrome's the default browser on this version, but the native one is often still installed). It'd be good to capture this too. The check's getting a bit unreadable though! Maybe it's regex time? if (/Android (2\.2|2\.3|4\.0|4\.1).* Mobile Safari/.test(ua) && ua.indexOf('Chrome') === -1) {
return false;
} |
Is there a way to programmatically detect a faulty History implementation without resorting to browser user agent sniffing? |
@jokeyrhyme — Here's the original discussion on this: #733... general consensus was that it would be hard to detect (certainly smoothly), but very happy to try and improve this if we can think of a way. This seems to cover versions which don't update Modernizr.addTest('history', function () {
var oldLoc = window.location.toString();
var result = false;
if (window.history && 'replaceState' in window.history) {
// Try changing history
window.history.replaceState({}, '', oldLoc + 'a');
result = window.location.toString() === oldLoc + 'a';
// Put it back how we found it
window.history.replaceState({}, '', oldLoc);
}
return result
}); But on 4.0.x and 4.1.x (maybe others too), the location object is updated correctly but the address bar isn't until refreshed. I have no idea how we can detect this without a UA sniff. Interestingly, on 4.1.2 at least, the address bar is updated correctly if |
This snif has been broken for quite a while, any chance to get this merged? One should also add the sniff for Android 4.1 since it's still broken there. It works on Chrome on Android though, so it should be a bit more specific. I can make a new PR with those changed ua sniffs, if it's gonna get merged :) |
It has to be updated since it can't be merged as is. There are a couple other broken tests that need to be backported. Once this is updated, we'll probably ship another minor version |
So should I make a new PR against master? |
I can whip it up, but in general that is what needs to happen, yes. |
The current thinking regarding user agent sniffing is that we should use feature detection to enable behaviours, and that it is acceptable to use user agent sniffing to disable behaviours. Obviously, we'd all love to live in a world where feature detection is all we need, but sometimes our only option is to explicitly blacklist specific browsers. |
update history ua snif, fixes #891
I just remembered, History.JS has special user agent detection in its blacklist as well: |
…ua-snif update history ua snif, fixes Modernizr#891
Modernizr.history returns a false positive with Android 4.0.4 stock browser.
This fixes it for Android 4.0.x more generally.
Main reasons why I track all 4.0.x versions here is:
Many people noticed Android 4.0.x stock browser is not fully supporting history.
More specifically, the address bar is not correctly updated.
StackOverflow:
http://stackoverflow.com/questions/10620843/pushstate-in-android-4-0.
Android project issues reports :
https://code.google.com/p/android/issues/detail?id=17471
https://code.google.com/p/android/issues/detail?id=23979