Skip to content

Commit ccb1324

Browse files
committed
Button: Ignore non-radio elements with the same name
Fixes #8761 Closes gh-1185
1 parent fa23894 commit ccb1324

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/unit/button/button_core.js

+14
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ test("radio groups", function() {
5353
assert(":eq(1)", ":eq(0)", ":eq(0)");
5454
});
5555

56+
test( "radio groups - ignore elements with same name", function() {
57+
expect( 1 );
58+
var form = $( "form:first" ),
59+
radios = form.find( "[type=radio]" ).button(),
60+
checkbox = $( "<input>", {
61+
type: "checkbox",
62+
name: radios.attr( "name" )
63+
});
64+
65+
form.append( checkbox );
66+
radios.button( "refresh" );
67+
ok( true, "no exception from accessing button instance of checkbox" );
68+
});
69+
5670
test("input type submit, don't create child elements", function() {
5771
expect( 2 );
5872
var input = $("#submit");

ui/button.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ var lastActive,
4040
if ( name ) {
4141
name = name.replace( /'/g, "\\'" );
4242
if ( form ) {
43-
radios = $( form ).find( "[name='" + name + "']" );
43+
radios = $( form ).find( "[name='" + name + "'][type=radio]" );
4444
} else {
45-
radios = $( "[name='" + name + "']", radio.ownerDocument )
45+
radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
4646
.filter(function() {
4747
return !this.form;
4848
});

0 commit comments

Comments
 (0)