From 065aef537b7533046907fcffc6896949e44679eb Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Wed, 3 Aug 2011 22:16:34 -0500 Subject: [PATCH] Button: Adding quotes to the attribute selector for labels - Fixes #7534 - Button label selector omits quotes / fails for ids with ":" --- tests/unit/button/button_tickets.js | 6 ++++++ ui/jquery.ui.button.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js index 2912b06a3..624d16716 100644 --- a/tests/unit/button/button_tickets.js +++ b/tests/unit/button/button_tickets.js @@ -50,4 +50,10 @@ test( "#7092 - button creation that requires a matching label does not find labe ok( group.find( "label" ).is( ".ui-button" ) ); }); +test( "#7534 - Button label selector works for ids with \":\"", function() { + var group = $( "" ); + group.find( "input" ).button(); + ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); +}); + })( jQuery ); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index ad17ab0c1..89c52d007 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -229,7 +229,7 @@ $.widget( "ui.button", { // we don't search against the document in case the element // is disconnected from the DOM 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 ); if ( !this.buttonElement.length ) { ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); -- 2.39.5