false positive in history management support detection #733

Closed
bitinn opened this Issue Oct 19, 2012 · 4 comments

Projects

None yet

4 participants

@bitinn
bitinn commented Oct 19, 2012

This issue has been known for a while but I haven't found a solid way to workaround it.

History API support used by modernizr and majority of routing frameworks does this:

!!(window.history && history.pushState)

This is fine on desktop browser, but for mobile browser, in particular android 2.2 - 4.0 and iOS 4, this leads to false positive, where they claim support for pushState, but has issue such as "location.pathname is not updated" or "address bar does not update"

reference:
http://code.google.com/p/android/issues/detail?id=17471
http://caniuse.com/#search=history

This is an issue because we cannot provide a fallback (e.g. hashchange) as it is not reliably detected.

one might say "forget it and let mobile device do a full refresh", but for Web App this is quite critical as full page rendering slow down workflow, even if we assume client-side caching is working.

Hope someone can comment on this.

@hay
Contributor
hay commented Nov 12, 2012

Yup, this is a pretty nasty bug that's difficult to detect (i don't know how you should detect the buggy behavior).

The biggest problem for me is window.location not giving the correct address (it never updates). This means writing a good router is difficult. For now, i don't know any other way to fix this than browser sniffing.

@paulirish
Member

This is legit.

Let's add a UA sniff in here.

There isn't another clean way to work around it.

@hay hay added a commit to hay/Modernizr that referenced this issue Nov 13, 2012
@hay hay #733: adding UA sniff for history support 45de935
@hay
Contributor
hay commented Nov 13, 2012

I've written a patch using UA sniffing. See: #746

When that is pulled this comment can be closed.

@hay hay added a commit to hay/Modernizr that referenced this issue Nov 19, 2012
@hay hay #733: adding UA sniff for history support 479e424
@SlexAxton SlexAxton added a commit to SlexAxton/Modernizr that referenced this issue Dec 3, 2012
@SlexAxton SlexAxton Merge branch 'master' of github.com:Modernizr/Modernizr
* 'master' of github.com:Modernizr/Modernizr:
  history check should check for Android 2
  made check a little clearer, removing a nested if statement
  only check for version of Android between 2 and 3
  #733: adding UA sniff for history support
  use addEventListener instead of DOM level 1 events (fixes #697)
  only check for version of Android between 2 and 3
  #733: adding UA sniff for history support
21f4d67
@sindresorhus
Member

Fixed in #746

@patrickkettner patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this issue Feb 22, 2015
@hay hay #733: adding UA sniff for history support c3b00de
@patrickkettner patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this issue Feb 22, 2015
@hay hay #733: adding UA sniff for history support 30973d4
@patrickkettner patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this issue Feb 22, 2015
@SlexAxton SlexAxton Merge branch 'master' of github.com:Modernizr/Modernizr
* 'master' of github.com:Modernizr/Modernizr:
  history check should check for Android 2
  made check a little clearer, removing a nested if statement
  only check for version of Android between 2 and 3
  #733: adding UA sniff for history support
  use addEventListener instead of DOM level 1 events (fixes #697)
  only check for version of Android between 2 and 3
  #733: adding UA sniff for history support
9914f33
@xyqfer xyqfer referenced this issue in sdc-alibaba/SUI-Mobile Apr 27, 2016
Open

路由返回在Android4.1.1上不能用 #616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment