]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Adding quotes to the attribute selector for labels - Fixes #7534 - Button...
authorCorey Frang <gnarf@gnarf.net>
Thu, 4 Aug 2011 03:16:34 +0000 (22:16 -0500)
committerCorey Frang <gnarf@gnarf.net>
Thu, 4 Aug 2011 03:16:34 +0000 (22:16 -0500)
tests/unit/button/button_tickets.js
ui/jquery.ui.button.js

index 2912b06a35350aa437f35946c353971c90857288..624d16716b046bc51074e3115e233888be23b26e 100644 (file)
@@ -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 = $( "<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 );
index ad17ab0c1809c3a8cd81063e197f2aadd7798b9f..89c52d007ee34e2d391b23d52d25d59b71e2a43d 100644 (file)
@@ -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();