Skip to content
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

$element.is(':focus') does not work on mobile Chrome (maybe Webkits in general) #385

Open
func0der opened this issue Aug 5, 2016 · 8 comments

Comments

@func0der
Copy link

@func0der func0der commented Aug 5, 2016

It seems that the $element.is(':focus') detection of jQuery and therefore Sizzle has troubles detecting the currently focused element in the Android version of the Chrome browser.

I have created fiffdle for this problem: https://jsfiddle.net/abcqLoaL/1/

I had the same issue in Safari on an iOS device. Maybe this is a webkit related problem.
Firefox works fine though. Desktop browser seem to handle it fine.

@dmethvin
Copy link
Member

@dmethvin dmethvin commented Aug 5, 2016

Looks like Chome fixed this bug at some point but the Webkit-based browsers still have it?

sizzle/src/sizzle.js

Lines 705 to 709 in b05a9d3

// qSa(:focus) reports false when true (Chrome 21)
// We allow this because of a bug in IE8/9 that throws an error
// whenever `document.activeElement` is accessed on an iframe
// So, we allow :focus to pass through QSA all the time to avoid the IE error
// See https://bugs.jquery.com/ticket/13378

@func0der
Copy link
Author

@func0der func0der commented Aug 5, 2016

I have Chrome 43 installed on my test phone. It does not seem to be fixed in it.

@dmethvin
Copy link
Member

@dmethvin dmethvin commented Aug 5, 2016

Interesting, it works on desktop Chrome 52. In any case, that comment explains why it can't be fixed in Sizzle without causing IE8/9 to throw errors, which is worse.

@func0der
Copy link
Author

@func0der func0der commented Aug 5, 2016

Yeah, it is not problem on desktop browsers.
It only occurs on mobile browsers.
I just got my hands on a Chrome 52 Android browser in which this problem seems to be fixed.
The Safari still had the issue.

So we leave this broken for some browsers? No workaround or double check here?

@mgol
Copy link
Member

@mgol mgol commented Aug 5, 2016

We'd need to know what to check and do a proper support test. The problem is we can't test focus-related things because we'd have to hijack the focus of the whole page and that's too disruptive.

Yes, there are cases that we're unable to workaround because there are no reliable detection ways and we try to avoid user agent sniffing.

If we know that the IE 8/9 issue is really only applicable to IE<10 (what about IE 6/7?), we might need to do an ugly check for document.documentMode here.

@func0der
Copy link
Author

@func0der func0der commented Aug 5, 2016

That's too bad.
I though the support for such browsers (6/7) gets dropped over time, because of the hassle of keeping it up.

So the only way to avoid this issue is on the developers end by checking for NOT IE8/9 and use $element.is(window.activeElement) in those cases.

@mgol
Copy link
Member

@mgol mgol commented Aug 5, 2016

@func0der Sizzle has broader browser support than jQuery; see https://github.com/jquery/sizzle/wiki#-browser-support. jQuery browser support is available at https://jquery.com/browser-support/.

@markelog
Copy link
Member

@markelog markelog commented Aug 6, 2016

Yeah, that's weird we still want to support those browsers :/. I'm sure @gibson042 has some reasons for it though.

My vote is just to drop it

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

No branches or pull requests

4 participants