Revert "Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369."

This reverts commit bba8366af4.

Because cross-frame focus sucks.
This commit is contained in:
Dave Methvin 2013-10-22 22:47:34 -04:00
parent bba8366af4
commit 469150a27e
3 changed files with 7 additions and 59 deletions

View File

@ -892,29 +892,22 @@ if ( !support.changeBubbles ) {
if ( !support.focusinBubbles ) { if ( !support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout // Attach a single capturing handler while someone wants focusin/focusout
var handler = function( event ) { var attaches = 0,
handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
}; };
jQuery.event.special[ fix ] = { jQuery.event.special[ fix ] = {
setup: function() { setup: function() {
var doc = this.ownerDocument, if ( attaches++ === 0 ) {
attaches = jQuery._data( doc, "focusCount" ); document.addEventListener( orig, handler, true );
if ( !attaches ) {
doc.addEventListener( orig, handler, true );
} }
jQuery._data( doc, "focusCount", ( attaches || 0 ) + 1 );
}, },
teardown: function() { teardown: function() {
var doc = this.ownerDocument, if ( --attaches === 0 ) {
attaches = jQuery._data( doc, "focusCount" ) - 1; document.removeEventListener( orig, handler, true );
if ( !attaches ) {
doc.removeEventListener( orig, handler, true );
} }
jQuery._data( doc, "focusCount", attaches );
} }
}; };
}); });

View File

@ -1,18 +0,0 @@
<!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>

View File

@ -2507,33 +2507,6 @@ test("fixHooks extensions", function() {
jQuery.event.fixHooks.click = saved; jQuery.event.fixHooks.click = saved;
}); });
testIframeWithCallback( "focusin from an iframe", "event/focusinCrossFrame.html", function( frameDoc ) {
expect(1);
var input = jQuery( frameDoc ).find( "#frame-input" );
// Create a focusin handler on the parent; shouldn't affect the iframe's fate
jQuery ( "body" ).on( "focusin.iframeTest", function() {
ok( false, "fired a focusin event in the parent document" );
});
input.on( "focusin", function() {
ok( true, "fired a focusin event in the iframe" );
});
// Avoid a native event; Chrome can't force focus to another frame
input.trigger( "focusin" );
// Must manually remove handler to avoid leaks in our data store
input.remove();
// Be sure it was removed; nothing should happen
input.trigger( "focusin" );
// Remove body handler manually since it's outside the fixture
jQuery( "body" ).off( "focusin.iframeTest" );
});
testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) { testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) {
expect(1); expect(1);
ok( isOk, "$.when( $.ready ) works" ); ok( isOk, "$.when( $.ready ) works" );