Skip to content

Commit 1f16138

Browse files
tjvantollscottgonzalez
authored andcommitted
Button: Corrected default label applied to submit buttons. Fixed #8337: Submit inputs don't automatically set label option.
1 parent 286941e commit 1f16138

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tests/unit/button/button_options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ test("text false with icon", function() {
5353
test("label, default", function() {
5454
$("#button").button();
5555
deepEqual( $("#button").text(), "Label" );
56+
deepEqual( $( "#button").button( "option", "label" ), "Label" );
5657

5758
$("#button").button("destroy");
5859
});
@@ -62,19 +63,22 @@ test("label", function() {
6263
label: "xxx"
6364
});
6465
deepEqual( $("#button").text(), "xxx" );
66+
deepEqual( $("#button").button( "option", "label" ), "xxx" );
6567

6668
$("#button").button("destroy");
6769
});
6870

6971
test("label default with input type submit", function() {
7072
deepEqual( $("#submit").button().val(), "Label" );
73+
deepEqual( $("#submit").button( "option", "label" ), "Label" );
7174
});
7275

7376
test("label with input type submit", function() {
7477
var label = $("#submit").button({
7578
label: "xxx"
7679
}).val();
7780
deepEqual( label, "xxx" );
81+
deepEqual( $("#submit").button( "option", "label" ), "xxx" );
7882
});
7983

8084
test("icons", function() {

ui/jquery.ui.button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $.widget( "ui.button", {
7373
focusClass = "ui-state-focus";
7474

7575
if ( options.label === null ) {
76-
options.label = this.buttonElement.html();
76+
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
7777
}
7878

7979
this.buttonElement

0 commit comments

Comments
 (0)