Skip to content

Commit cc7df71

Browse files
committed
Button: properly escape button names. Fixes #7505 - Button: Buttonset not applied to radio group with quotation/apostrophe in name.
1 parent 4334b5d commit cc7df71

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

tests/unit/button/button.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ <h2 id="qunit-userAgent"></h2>
5959
<input type="radio" id="radio23" name="radio" checked="checked"><label for="radio23">Choice 3</label>
6060
</div>
6161
</form>
62+
<form>
63+
<div id="radio3">
64+
<input type="radio" id="radio31" name="data['Page']['parse']" /><label for="radio31">Choice 1</label>
65+
<input type="radio" id="radio32" name="data['Page']['parse']" checked="checked" /><label for="radio32">Choice 2</label>
66+
<input type="radio" id="radio33" name="data['Page']['parse']" /><label for="radio33">Choice 3</label>
67+
</div>
68+
</form>
6269

6370
<input type="checkbox" id="check"><label for="check">Toggle</label>
6471

tests/unit/button/button_events.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
/*
22
* button_events.js
33
*/
4-
(function() {
4+
(function($) {
55

66
module("button: events");
77

8+
test("buttonset works with single-quote named elements (#7505)", function() {
9+
expect( 1 );
10+
$("#radio3").buttonset();
11+
$("#radio33").click( function(){
12+
ok( true, "button clicks work with single-quote named elements" );
13+
}).click();
14+
});
15+
816
})(jQuery);

ui/jquery.ui.button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var lastActive, startXPos, startYPos, clickDragged,
2929
form = radio.form,
3030
radios = $( [] );
3131
if ( name ) {
32+
name = name.replace( /'/g, "\\'" );
3233
if ( form ) {
3334
radios = $( form ).find( "[name='" + name + "']" );
3435
} else {

0 commit comments

Comments
 (0)