#13378 closed bug (wontfix)
ie8 & ie9 iframe - .filter(":focus") - document.activeElement returns unspecified error.
Reported by: | muzzamo | Owned by: | Timmy Willison |
---|---|---|---|
Priority: | low | Milestone: | 1.10 |
Component: | selector | Version: | 1.9.0 |
Keywords: | Cc: | Timmy Willison | |
Blocked by: | Blocking: |
Description
Unfortunately I am unable to put this into jsfiddle/jsbin due to issues with scripts in iframes on both of these sites. It can be reproduced if you place the following two files in a folder on the file system and open outer.html in ie9:
outer.html
<!DOCTYPE html> <html lang="en"> <body> <div style="border: 1px solid black"> <iframe src="inner.html" style="width:1024px; height:768px;"></iframe> </div> </body> </html>
inner.html
<!DOCTYPE html> <html lang="en"> <head> <script src="http://code.jquery.com/jquery-1.9.0.js"></script> <!--<script src="http://code.jquery.com/jquery-git.js"></script>--> </head> <body> <a id="link" href="http://www.google.com">google</a> <script> $("#link").filter(":focus"); </script> </html>
To make sure that internet explorer executes scripts when loaded this way go to internet options -> advanced -> security -> "Allow active content to run in files on My Computer*". Then when you load the page in ie, a popup will appear at the bottom saying "Internet explorer restricted this webpage from running scripts or ActiveX controls.", click "Allow blocked content".
Make sure the script debugger is enabled (F12 developer tools -> script -> start debugging).
This is occurring on line 4869 of jquery-1.9.0.js. This also occurred on jquery 1.8.x. This is also occurring in jquery-git.js v 2013-2-3 on line 4877.
This occurs on ie8 and ie9 (ie7, ie10 not tested), and does not occur on firefox and chrome.
I believe this was first reported in jquery UI ticket 8443 (http://bugs.jqueryui.com/ticket/8443) which was closed due to not enough information. The issue applies to jquery core.
The workaround for this bug is to add the following to the iframe.html file:
<script> jQuery(function () { document.documentElement.focus(); }); </script>
This issue was first reported as a defect in kendo UI v2012.3.1315 in the menu widget, which depends on JQuery 1.8.x.
Change History (17)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Cc: | Timmy Willison added |
---|---|
Component: | unfiled → selector |
Priority: | undecided → low |
Status: | new → open |
The exception is thrown on access of document.activeElement
in the framed page, and document.hasFocus()
frustratingly returns true
. We can either stick a try…catch
in the ":focus" filter or wontfix this ticket, but I don't see a third option.
comment:3 Changed 10 years ago by
One remark on this one: it doesn't always occur though. If I open the page in IE9 on the webserver itself, there are no problems for me. This only occurs when I try opening a page from another location as the webserver (beats me).
comment:4 follow-up: 6 Changed 10 years ago by
I use to have the same issue. As far as my experience I found two workarounds for this problem:
- call document.documentElement.focus() - this will somehow force document invalidation
- use document.documentElement.activeElement instead of document.activeElement
Hope it help someone.
comment:5 Changed 10 years ago by
I've been experiencing a very similar issue with an IFrame on IE when calling the following bit of code:
$("input[autofocus]").focus();
This blows up on line 3254 of jquery-1.9.1.js, apparently on the following command:
(this !== document.activeElement)
Would be great if this could be fixed....
comment:6 Changed 10 years ago by
Replying to nikolay.r.rusev@…:
I use to have the same issue. As far as my experience I found two workarounds for this problem:
- call document.documentElement.focus() - this will somehow force document invalidation
- use document.documentElement.activeElement instead of document.activeElement
Hope it help someone.
===============
- use document.documentElement.activeElement instead of document.activeElement
This works for me. Thanks for the post! Van Thi
comment:7 Changed 10 years ago by
This has caused several high-priority problems for us in the past few weeks. I think the priority of this bug should be escalated.
Thanks to those who have posted workarounds though!
comment:8 Changed 10 years ago by
Thanks for the workarounds! Recently upgraded to 1.9.1 and our gallery (which is loaded in an iframe) stopped working. I would love to see this one fixed.
Thanks!
comment:9 Changed 10 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | open → assigned |
comment:10 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Update Sizzle: use documentElement in focus selector. Fixes #13378.
Changeset: aadae5058a44e745ebdbee5d5333402699326188
comment:11 Changed 10 years ago by
Milestone: | None → 1.10 |
---|
comment:12 Changed 10 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:13 Changed 10 years ago by
Unfortunately, the test that made sure that it didn't throw an error was passing because documentElement.activeElement is just undefined
. We will not be fixing this because the only solutions are either a try/catch
or calling document.focus()
, neither of which we are willing to do. However, we had bypassed QSA for all :focus
selectors due to a Chrome bug. We will instead let :focus
always pass through QSA so IE doesn't throw an error (except in a few edge cases), but Chrome will be wrong sometimes.
comment:14 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
Allowed :focus
to pass through QSA. https://github.com/jquery/sizzle/commit/9ff2bbbf39b0040fcddf6f38ef884952e9f4e58c
comment:15 Changed 10 years ago by
If Chrome has a bug here it should probably be reported to them and linked to this meta bug:
https://code.google.com/p/chromium/issues/detail?id=176671
(I'm not doing it myself because I don't know the details of this bug).
Fortunately, if/when they fix it this problem just disappears for us because of Chrome rapid release pace; can't say the same about IE.
comment:16 Changed 10 years ago by
The bug has been fixed in browsers that jQuery supports. It is only an issue for Sizzle.
I have now created a jsfiddle for this as well.
Make sure the script debugger is enabled in ie.
http://jsfiddle.net/muzzamo/2taTW/