Skip to content

Commit

Permalink
Button: Read disabled attribute from original element if disabled opt…
Browse files Browse the repository at this point in the history
…ion is null. Fixes #5252 -Button: read disabled option from input elements.
  • Loading branch information
scottgonzalez committed Aug 18, 2010
1 parent 9060bf3 commit 2838c11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/unit/button/button_defaults.js
Expand Up @@ -3,7 +3,7 @@
*/

var button_defaults = {
disabled: false,
disabled: null,
text: true,
label: null,
icons: {
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/button/button_options.js
Expand Up @@ -5,6 +5,30 @@

module("button: options");

test("disabled, explicity value", function() {
$("#radio01").button({ disabled: false });
same(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
same(false, $("#radio01").attr("disabled"), "element is disabled");

$("#radio02").button({ disabled: true });
same(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
same(true, $("#radio02").attr("disabled"), "element is not disabled");
});

test("disabled, null", function() {
$("#radio01").button({ disabled: null });
same(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
same(false, $("#radio01").attr("disabled"), "element is disabled");

$("#radio02").attr("disabled", "disabled").button({ disabled: null });
same(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
same(true, $("#radio02").attr("disabled"), "element is not disabled");
});

test("text false without icon", function() {
$("#button").button({
text: false
Expand Down
5 changes: 5 additions & 0 deletions ui/jquery.ui.button.js
Expand Up @@ -44,6 +44,7 @@ var lastActive,

$.widget( "ui.button", {
options: {
disabled: null,
text: true,
label: null,
icons: {
Expand All @@ -56,6 +57,10 @@ $.widget( "ui.button", {
.unbind( "reset.button" )
.bind( "reset.button", formResetHandler );

if ( typeof this.options.disabled !== "boolean" ) {
this.options.disabled = this.element.attr( "disabled" );
}

this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );

Expand Down

0 comments on commit 2838c11

Please sign in to comment.