Skip to content

Commit 065aef5

Browse files
committed
Button: Adding quotes to the attribute selector for labels - Fixes #7534 - Button label selector omits quotes / fails for ids with ":"
1 parent 6fb6856 commit 065aef5

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
@@ -229,7 +229,7 @@ $.widget( "ui.button", {
229229
// we don't search against the document in case the element
230230
// is disconnected from the DOM
231231
var ancestor = this.element.parents().last(),
232-
labelSelector = "label[for=" + this.element.attr("id") + "]";
232+
labelSelector = "label[for='" + this.element.attr("id") + "']";
233233
this.buttonElement = ancestor.find( labelSelector );
234234
if ( !this.buttonElement.length ) {
235235
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();

0 commit comments

Comments
 (0)