Skip to content

Commit

Permalink
Button: Corrected default label applied to submit buttons. Fixed #833…
Browse files Browse the repository at this point in the history
…7: Submit inputs don't automatically set label option.
  • Loading branch information
tjvantoll authored and scottgonzalez committed May 22, 2012
1 parent 286941e commit 1f16138
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/unit/button/button_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test("text false with icon", function() {
test("label, default", function() {
$("#button").button();
deepEqual( $("#button").text(), "Label" );
deepEqual( $( "#button").button( "option", "label" ), "Label" );

$("#button").button("destroy");
});
Expand All @@ -62,19 +63,22 @@ test("label", function() {
label: "xxx"
});
deepEqual( $("#button").text(), "xxx" );
deepEqual( $("#button").button( "option", "label" ), "xxx" );

$("#button").button("destroy");
});

test("label default with input type submit", function() {
deepEqual( $("#submit").button().val(), "Label" );
deepEqual( $("#submit").button( "option", "label" ), "Label" );
});

test("label with input type submit", function() {
var label = $("#submit").button({
label: "xxx"
}).val();
deepEqual( label, "xxx" );
deepEqual( $("#submit").button( "option", "label" ), "xxx" );
});

test("icons", function() {
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.button.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $.widget( "ui.button", {
focusClass = "ui-state-focus";

if ( options.label === null ) {
options.label = this.buttonElement.html();
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
}

this.buttonElement
Expand Down

0 comments on commit 1f16138

Please sign in to comment.