Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
- Loading branch information
Showing
3 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | ||
<title>focusin event cross-frame (#14180)</title> | ||
|
||
<script src="../../jquery.js"></script> | ||
</head> | ||
<body> | ||
<input type="text" id="frame-input" /> | ||
<script> | ||
// Call parent when this frame is fully loaded, it will mess with #frame-input | ||
jQuery( window ).one( "load", function() { | ||
window.parent.iframeCallback( document ); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1cecf64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On jQuery 1.8.3 we were having this issue at Wikimedia. I patched around it with a similar approach.
However before I finished the upgrade I wanted to verify that that monkey-patch was no longer needed and was baffled that the test was passing on plain jQuery 1.8.3 without any patch. Turns out the unit test was flawed and I fear this one is flawed too.
When the event is triggered via
.trigger( "focusin" )
it always works. Presumably because that bypasses the critical path.I fixed my unit test by calling
.focus()
on the reference to the iframe's input node object directly.1cecf64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Krinkle I've just noticed your comment when investigating another issue. Test fixed in #4656.😅
1cecf64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgol Awesome, thanks! (And yeah, nowadays I would've filed an issue for this. Not sure why I didn't.)