Skip to content

Commit 657c2f8

Browse files
dmethvingibson042
authored andcommitted
Event: Fix delegated radio events when arrow keys are used
Fixes gh-2343, gh-2410 Close gh-2617 (cherry picked from commit c82a668)
1 parent f5328b6 commit 657c2f8

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/event.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ jQuery.event = {
514514
// Find delegate handlers
515515
// Black-hole SVG <use> instance trees (#13180)
516516
//
517-
// Support: Firefox
518-
// Avoid non-left-click bubbling in Firefox (#3861)
519-
if ( delegateCount && cur.nodeType && ( !event.button || event.type !== "click" ) ) {
517+
// Support: Firefox<=42+
518+
// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
519+
if ( delegateCount && cur.nodeType &&
520+
( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
520521

521522
/* jshint eqeqeq: false */
522523
for ( ; cur != this; cur = cur.parentNode || this ) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Test for gh-2343 (IE11)</title>
7+
<script src="../../dist/jquery.js"></script>
8+
<script>
9+
$(document).ready(function() {
10+
$( "fieldset" ).on( "click", "input", function() {
11+
$( ".result" ).append( "click " + this.value + "<br />" );
12+
} );
13+
} );
14+
</script>
15+
</head>
16+
17+
<body>
18+
19+
<h1>Test for gh-2343 (IE11)</h1>
20+
<p>
21+
Instructions: In <b>IE11</b>, click on or focus the first radio button.
22+
Then use the left/right arrow keys to select the other radios.
23+
You should see events logged in the results below.
24+
</p>
25+
<fieldset>
26+
<input type="radio" name="rad" value="0" /> 0
27+
<input type="radio" name="rad" value="1" /> 1
28+
<input type="radio" name="rad" value="2" /> 2
29+
</fieldset>
30+
<div class="result"></div>
31+
32+
</body>
33+
</html>

0 commit comments

Comments
 (0)