Skip to content

Commit 5dad57e

Browse files
committed
Buttonset: Added items option and removed visible filter for adding rounded corners. Fixes #6262 - buttonset not applying ui-corner to invisible elements.
1 parent fce1f97 commit 5dad57e

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

tests/unit/button/button_tickets.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
/*
22
* button_tickets.js
33
*/
4-
(function($) {
4+
(function( $ ) {
55

6-
module("button: tickets");
6+
module( "button: tickets" );
77

8-
test("#5946 - buttonset should ignore buttons that are not :visible", function() {
9-
$( "#radio01" ).next().wrap( "<div></div>" ).parent().hide();
10-
var set = $( "#radio0" ).buttonset();
11-
ok( set.find( "label:eq(0)" ).is( ".ui-button:not(.ui-corner-left)" ) );
8+
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
9+
$( "#radio01" ).next().andSelf().hide();
10+
var set = $( "#radio0" ).buttonset({ items: ":radio:visible" });
11+
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
1212
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
1313
});
1414

15-
})(jQuery);
15+
test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
16+
$( "#radio0" ).hide();
17+
var set = $( "#radio0" ).buttonset();
18+
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
19+
ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
20+
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
21+
});
22+
23+
})( jQuery );

ui/jquery.ui.button.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ $.widget( "ui.button", {
315315
});
316316

317317
$.widget( "ui.buttonset", {
318+
options: {
319+
items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
320+
},
321+
318322
_create: function() {
319323
this.element.addClass( "ui-buttonset" );
320324
},
@@ -332,7 +336,7 @@ $.widget( "ui.buttonset", {
332336
},
333337

334338
refresh: function() {
335-
this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" )
339+
this.buttons = this.element.find( this.options.items )
336340
.filter( ":ui-button" )
337341
.button( "refresh" )
338342
.end()
@@ -343,13 +347,11 @@ $.widget( "ui.buttonset", {
343347
return $( this ).button( "widget" )[ 0 ];
344348
})
345349
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
346-
.filter( ":visible" )
347-
.filter( ":first" )
348-
.addClass( "ui-corner-left" )
349-
.end()
350-
.filter( ":last" )
351-
.addClass( "ui-corner-right" )
352-
.end()
350+
.filter( ":first" )
351+
.addClass( "ui-corner-left" )
352+
.end()
353+
.filter( ":last" )
354+
.addClass( "ui-corner-right" )
353355
.end()
354356
.end();
355357
},

0 commit comments

Comments
 (0)