Button: Read disabled attribute from original element if disabled option is null. Fixes #5252 -Button: read disabled option from input elements.

This commit is contained in:
Scott González 2010-08-18 14:51:30 -04:00
parent 9060bf3d09
commit 2838c11ea8
3 changed files with 30 additions and 1 deletions

View File

@ -3,7 +3,7 @@
*/ */
var button_defaults = { var button_defaults = {
disabled: false, disabled: null,
text: true, text: true,
label: null, label: null,
icons: { icons: {

View File

@ -5,6 +5,30 @@
module("button: options"); 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() { test("text false without icon", function() {
$("#button").button({ $("#button").button({
text: false text: false

View File

@ -44,6 +44,7 @@ var lastActive,
$.widget( "ui.button", { $.widget( "ui.button", {
options: { options: {
disabled: null,
text: true, text: true,
label: null, label: null,
icons: { icons: {
@ -56,6 +57,10 @@ $.widget( "ui.button", {
.unbind( "reset.button" ) .unbind( "reset.button" )
.bind( "reset.button", formResetHandler ); .bind( "reset.button", formResetHandler );
if ( typeof this.options.disabled !== "boolean" ) {
this.options.disabled = this.element.attr( "disabled" );
}
this._determineButtonType(); this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" ); this.hasTitle = !!this.buttonElement.attr( "title" );