-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
Edge: .is(":focus") and .not(":focus") return wrong values #4109
Comments
Thanks for opening an issue. However, I copied the test case to jsfiddle and I cannot reproduce. https://jsfiddle.net/63zby1nt/show |
Without reproducing, there's not much we can do. |
FWIW, that fiddle reproduces the reported behavior in Edge 42.17134.1.0 for me - when page is refreshed it logs
|
@fastfasterfastest I see that result as well. However, it's possible that Edge still has the async-focus behavior that the old IEs had. Focus didn't occur until the next event loop turn. If I change it to |
I hadn't really studied the issue reported and was just commenting on @timmywil statement he couldn't reproduce the reported behavior, while I could, even with @timmywil's fiddle.
What is the result you get and what is the result you expect? If I change to do the logging in a (It appears when you refresh the page, Edge does not actually cause the focus to be set to the input element at all...) |
When I first used the original fiddle I got your results. When I used the updated fiddle I got: input focused: true
input#first focused: true
input:focus id: first
$('input').not(':focus').length: 1
$('input:not(:focus)').length: 1
focused count: 1 Now I get the |
I did too - until I realized I was using Chrome... maybe you did too? Using Edge, I get consistent results. And you must refresh the page per @komarovalexander's report to see the reported behavior. Using the updated fiddle in Edge, I initially get (prior to the refresh):
When the page is refreshed I get:
|
Note, I was not the original reporter. Nevertheless, here is a fiddle without jquery and it seems to behave "correctly" - https://jsfiddle.net/63zby1nt/9/show Here is a fiddle w/ jquery and some
(Also strange (?) is that the focus is not actually in the input element after the refresh - the caret is not in the input element.) |
Even the That said, I opened Edge, pasted in the URL, and hit enter. This is the result I got: input focused - $('input').is(':focus'): true
input focused - qsa('input')~.any(':focus'):true
input#first focused: true
input:focus id: first
not focus count - $('input').not(':focus').length: 1
not focus count - qsa('input')~.length:1
qsa('input:not(:focus)').length: 1
$('input:not(:focus)').length: 1
focused count - $('input:focus').length: 1
focused count - qsa('input:focus').length: 1 |
Again, you need to refresh the page and/to see the issue. Do what you did, then refresh the page. |
It seems like the issue the OP is reporting may be due to that Edge does not "fully" set focus to the input element after the page has been reloaded using the browser's "Refresh" button. When the page is reloaded using the browser's "Refresh" button it appears that the document is not given focus, as seen by probing Nevertheless, I was curious and looked into this a little bit and noticed something interesting/weird, perhaps a bug, in jquery in this particular situation. It is not necessarily causing the issue the OP reports, but may contribute to some confusion. I noticed that the value of In the sample below, This is due to that two different code paths are taken in jquery depending on whether The result is (*: This is strange by itself from a logic point of view - Here is the sample that demonstrates this - I provide it, not as a fiddle to avoid any iframe issues coming into play, as code you have to save to a file and load in Edge.
|
I think there is an issue with jquery/Sizzle here, regardless of whether Edge "fully" sets focus after a reload or not. jquery uses two different ways to determine the value of So to restate, hopefully little clearer... For sample code demonstrating the issue, see preceding comment above #4109 (comment) Condition: using Edge and page must be reloaded by using browser's "Refresh" button. Note, the page must be reloaded using browser's "Refresh" button to demonstrate the issue. Assume the First issue is that the value of
Second issue is that if
(I don't know if this should be opened as an issue at https://github.com/jquery/sizzle/issues instead) |
Thanks for the analysis! I think it''s fine to file it here for now until we figure out whether and how this can be fixed. |
Thank you for the thorough analysis. I'm almost positive, tho, that this issue should be migrated to Sizzle, so here we go: jquery/sizzle#424 |
jQuery 3.7.0 will not include Sizzle anymore so I'll reopen. That said, we're dropping EdgeHTML support in jQuery 4.0.0 so this will be a 3.x-only item, unlikely to be fixed by the jQuery Core team. We'd be happy to review PRs, though. |
Description
code for reproducing:
When I use Edge I have strange behavior of .is(":focus") and .not(".focus")
How it should work?
all browsers:
edge (if you click by page after reload):
What is wrong?
edge: if you do not click by page after reload, you will get these results (you can click by page tab if it is not reproduced):
element is focused and selectors fetch it. But if you use .is() and .not() you will get wrong results
I reproduced it in my tests and I have to spend time to find reasons why sometimes it is working and sometimes is not working
Which browsers are affected?
Microsoft Edge
my version is
Microsoft Edge 42.17134.1.0
Microsoft EdgeHTML 17.17134
other browsers are ok.
test case is attached
test_to_reproduce.zip
The text was updated successfully, but these errors were encountered: