diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2015-09-27 22:05:57 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2015-10-25 15:07:50 -0400 |
commit | 657c2f818075111684ff8e0406dbb74f2b8cdc21 (patch) | |
tree | 1b30b1fade2fa5840313a8e285b6474524f7225d | |
parent | f5328b6a447f23fd8fb9465db36b6eb46e9d8ba6 (diff) | |
download | jquery-657c2f818075111684ff8e0406dbb74f2b8cdc21.tar.gz jquery-657c2f818075111684ff8e0406dbb74f2b8cdc21.zip |
Event: Fix delegated radio events when arrow keys are used
Fixes gh-2343, gh-2410
Close gh-2617
(cherry picked from commit c82a6685bb964627e27008e298f93ea81218265b)
-rw-r--r-- | src/event.js | 7 | ||||
-rw-r--r-- | test/integration/gh-2343-ie-radio-click.html | 33 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/event.js b/src/event.js index e93a27093..f7af22083 100644 --- a/src/event.js +++ b/src/event.js @@ -514,9 +514,10 @@ jQuery.event = { // Find delegate handlers // Black-hole SVG <use> instance trees (#13180) // - // Support: Firefox - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && cur.nodeType && ( !event.button || event.type !== "click" ) ) { + // Support: Firefox<=42+ + // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) + if ( delegateCount && cur.nodeType && + ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { /* jshint eqeqeq: false */ for ( ; cur != this; cur = cur.parentNode || this ) { diff --git a/test/integration/gh-2343-ie-radio-click.html b/test/integration/gh-2343-ie-radio-click.html new file mode 100644 index 000000000..4bc6956c3 --- /dev/null +++ b/test/integration/gh-2343-ie-radio-click.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html> +<head lang="en"> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <title>Test for gh-2343 (IE11)</title> + <script src="../../dist/jquery.js"></script> + <script> + $(document).ready(function() { + $( "fieldset" ).on( "click", "input", function() { + $( ".result" ).append( "click " + this.value + "<br />" ); + } ); + } ); + </script> +</head> + +<body> + +<h1>Test for gh-2343 (IE11)</h1> +<p> +Instructions: In <b>IE11</b>, click on or focus the first radio button. +Then use the left/right arrow keys to select the other radios. +You should see events logged in the results below. +</p> +<fieldset> + <input type="radio" name="rad" value="0" /> 0 + <input type="radio" name="rad" value="1" /> 1 + <input type="radio" name="rad" value="2" /> 2 +</fieldset> +<div class="result"></div> + +</body> +</html> |