mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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:
parent
9060bf3d09
commit
2838c11ea8
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
var button_defaults = {
|
||||
disabled: false,
|
||||
disabled: null,
|
||||
text: true,
|
||||
label: null,
|
||||
icons: {
|
||||
|
@ -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
|
||||
|
5
ui/jquery.ui.button.js
vendored
5
ui/jquery.ui.button.js
vendored
@ -44,6 +44,7 @@ var lastActive,
|
||||
|
||||
$.widget( "ui.button", {
|
||||
options: {
|
||||
disabled: null,
|
||||
text: true,
|
||||
label: null,
|
||||
icons: {
|
||||
@ -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" );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user