]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Ignore non-radio elements with the same name
authorTJ VanToll <tj.vantoll@gmail.com>
Tue, 28 Jan 2014 15:46:23 +0000 (10:46 -0500)
committerTJ VanToll <tj.vantoll@gmail.com>
Tue, 28 Jan 2014 15:58:30 +0000 (10:58 -0500)
Fixes #8761
Closes gh-1185

tests/unit/button/button_core.js
ui/button.js

index 41623e08dfaa089c866e078ee3ab62e2c81f200b..f647cdc26b1ed2653d77cb8bfff601ec13d940c2 100644 (file)
@@ -53,6 +53,20 @@ test("radio groups", function() {
        assert(":eq(1)", ":eq(0)", ":eq(0)");
 });
 
+test( "radio groups - ignore elements with same name", function() {
+       expect( 1 );
+       var form = $( "form:first" ),
+               radios = form.find( "[type=radio]" ).button(),
+               checkbox = $( "<input>", {
+                       type: "checkbox",
+                       name: radios.attr( "name" )
+               });
+
+       form.append( checkbox );
+       radios.button( "refresh" );
+       ok( true, "no exception from accessing button instance of checkbox" );
+});
+
 test("input type submit, don't create child elements", function() {
        expect( 2 );
        var input = $("#submit");
index 4b401e1a3faed6446cca2248cd28bc70d79a1fb8..96fea440f320376ea8bcde94d0794e21cdd98404 100644 (file)
@@ -40,9 +40,9 @@ var lastActive,
                if ( name ) {
                        name = name.replace( /'/g, "\\'" );
                        if ( form ) {
-                               radios = $( form ).find( "[name='" + name + "']" );
+                               radios = $( form ).find( "[name='" + name + "'][type=radio]" );
                        } else {
-                               radios = $( "[name='" + name + "']", radio.ownerDocument )
+                               radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
                                        .filter(function() {
                                                return !this.form;
                                        });