diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-01-19 22:14:24 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-01-19 22:14:24 -0500 |
commit | 8d9025ca50603e5404c6b50f7fa6c87046ee24c1 (patch) | |
tree | 7ee72835aee4e9df9db426f2a1158afb224b5002 /src/event.js | |
parent | 2982abbb13454bd4bdf0299f1183fb0d8c02f02d (diff) | |
download | jquery-8d9025ca50603e5404c6b50f7fa6c87046ee24c1.tar.gz jquery-8d9025ca50603e5404c6b50f7fa6c87046ee24c1.zip |
Fix #8165: Ignore events bubbling through disabled elements.
Although #6911 fixed the case where event.target was disabled, it missed the case where the target was a sub-element.
Diffstat (limited to 'src/event.js')
-rw-r--r-- | src/event.js | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/event.js b/src/event.js index c675937a3..63dd7da6b 100644 --- a/src/event.js +++ b/src/event.js @@ -398,33 +398,37 @@ jQuery.event = { event.delegateTarget = this; // Determine handlers that should run if there are delegated events - // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) - if ( delegateCount && event.target.disabled !== true && !(event.button && event.type === "click") ) { + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !(event.button && event.type === "click") ) { // Pregenerate a single jQuery object for reuse with .is() jqcur = jQuery(this); jqcur.context = this.ownerDocument || this; for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { - selMatch = {}; - matches = []; - jqcur[0] = cur; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - - if ( selMatch[ sel ] === undefined ) { - selMatch[ sel ] = ( - handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) - ); + + // Don't process events on disabled elements (#6911, #8165) + if ( cur.disabled !== true ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } } - if ( selMatch[ sel ] ) { - matches.push( handleObj ); + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); } } - if ( matches.length ) { - handlerQueue.push({ elem: cur, matches: matches }); - } } } |