Skip to content

Commit

Permalink
Button: Adding quotes to the attribute selector for labels - Fixes #7…
Browse files Browse the repository at this point in the history
…534 - Button label selector omits quotes / fails for ids with ":"
  • Loading branch information
gnarf committed Aug 4, 2011
1 parent 6fb6856 commit 065aef5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/unit/button/button_tickets.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ test( "#7092 - button creation that requires a matching label does not find labe
ok( group.find( "label" ).is( ".ui-button" ) ); ok( group.find( "label" ).is( ".ui-button" ) );
}); });


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

})( jQuery ); })( jQuery );
2 changes: 1 addition & 1 deletion ui/jquery.ui.button.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ $.widget( "ui.button", {
// we don't search against the document in case the element // we don't search against the document in case the element
// is disconnected from the DOM // is disconnected from the DOM
var ancestor = this.element.parents().last(), var ancestor = this.element.parents().last(),
labelSelector = "label[for=" + this.element.attr("id") + "]"; labelSelector = "label[for='" + this.element.attr("id") + "']";
this.buttonElement = ancestor.find( labelSelector ); this.buttonElement = ancestor.find( labelSelector );
if ( !this.buttonElement.length ) { if ( !this.buttonElement.length ) {
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
Expand Down

0 comments on commit 065aef5

Please sign in to comment.