Skip to content

Commit 07d5271

Browse files
committed
Button: Adding quotes to the attribute selector for labels - Fixes #7534 - Button label selector omits quotes / fails for ids with ":"
(cherry picked from commit 065aef5) Conflicts: ui/jquery.ui.button.js
1 parent 14ab4f4 commit 07d5271

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tests/unit/button/button_tickets.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,10 @@ test( "#7092 - button creation that requires a matching label does not find labe
5050
ok( group.find( "label" ).is( ".ui-button" ) );
5151
});
5252

53+
test( "#7534 - Button label selector works for ids with \":\"", function() {
54+
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
55+
group.find( "input" ).button();
56+
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
57+
});
58+
5359
})( jQuery );

ui/jquery.ui.button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ $.widget( "ui.button", {
227227
// we don't search against the document in case the element
228228
// is disconnected from the DOM
229229
var ancestor = this.element.parents().filter(":last"),
230-
labelSelector = "label[for=" + this.element.attr("id") + "]";
230+
labelSelector = "label[for='" + this.element.attr("id") + "']";
231231
this.buttonElement = ancestor.find( labelSelector );
232232
if ( !this.buttonElement.length ) {
233233
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();

0 commit comments

Comments
 (0)