Commit 511c9fe7 authored by Dave Methvin's avatar Dave Methvin

Fix focus/blur unit test issues. Reopens #6705.

In the event refactor, I tried to have the focus/blur events trigger the focus/blur plus focusin/focusout events but this doesn't handle various real-world cases that expect a trigger()ed jQuery handler to run and be able to pass data even if the native event shouldn't fire.

This reopens a bug that causes a double-fire of
inline event handlers.
parent 307b1a3d
...@@ -27,14 +27,6 @@ var rnamespaces = /\.(.*)$/, ...@@ -27,14 +27,6 @@ var rnamespaces = /\.(.*)$/,
(!m[3] || m[3].test( elem.className )) && (!m[3] || m[3].test( elem.className )) &&
(!m[4] || elem.getAttribute( m[4] ) == m[5]) (!m[4] || elem.getAttribute( m[4] ) == m[5])
); );
},
useNativeMethod = function( event ) {
// IE throws error on focus/blur of a hidden element (#1486)
var type = event.type;
if ( !event.isDefaultPrevented() && this[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) ) {
this[ type ]();
return false;
}
}; };
/* /*
...@@ -102,7 +94,6 @@ jQuery.event = { ...@@ -102,7 +94,6 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers // handleObj is passed to all event handlers
// will be the result of merging handleObjIn
handleObj = jQuery.extend({ handleObj = jQuery.extend({
type: type, type: type,
origType: tns[1], origType: tns[1],
...@@ -357,7 +348,7 @@ jQuery.event = { ...@@ -357,7 +348,7 @@ jQuery.event = {
eventPath = []; eventPath = [];
addHandlers( elem, special.bindType || type ); addHandlers( elem, special.bindType || type );
doc = elem.ownerDocument; doc = elem.ownerDocument;
if ( doc && !jQuery.isWindow( elem ) & !event.isPropagationStopped() ) { if ( doc && !special.noBubble && !jQuery.isWindow( elem ) & !event.isPropagationStopped() ) {
bubbleType = special.delegateType || type; bubbleType = special.delegateType || type;
for ( cur = elem.parentNode; cur; cur = cur.parentNode ) { for ( cur = elem.parentNode; cur; cur = cur.parentNode ) {
addHandlers( cur, bubbleType ); addHandlers( cur, bubbleType );
...@@ -426,7 +417,7 @@ jQuery.event = { ...@@ -426,7 +417,7 @@ jQuery.event = {
// Determine handlers that should run if there are delegated events // Determine handlers that should run if there are delegated events
// Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
selMatch = {}; selMatch = {};
...@@ -566,11 +557,11 @@ jQuery.event = { ...@@ -566,11 +557,11 @@ jQuery.event = {
focus: { focus: {
delegateType: "focusin", delegateType: "focusin",
trigger: useNativeMethod noBubble: true
}, },
blur: { blur: {
delegateType: "focusout", delegateType: "focusout",
trigger: useNativeMethod noBubble: true
}, },
beforeunload: { beforeunload: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment