aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-01-11 21:20:24 +0100
committerFelix Nagel <info@felixnagel.com>2012-01-11 21:20:24 +0100
commit762131396e8c993b1bef3d786bbd6cc34dfb4bce (patch)
tree9cdfc179f4f18e42f4277ca6071b5dd950a3931a
parent8c17f74a1e64e134108f790d2527df18284ac9cc (diff)
downloadjquery-ui-762131396e8c993b1bef3d786bbd6cc34dfb4bce.tar.gz
jquery-ui-762131396e8c993b1bef3d786bbd6cc34dfb4bce.zip
Selectmenu: improved disabled state handling
-rw-r--r--tests/unit/selectmenu/selectmenu_methods.js9
-rw-r--r--ui/jquery.ui.selectmenu.js7
2 files changed, 10 insertions, 6 deletions
diff --git a/tests/unit/selectmenu/selectmenu_methods.js b/tests/unit/selectmenu/selectmenu_methods.js
index 263d27be2..5935f3ea0 100644
--- a/tests/unit/selectmenu/selectmenu_methods.js
+++ b/tests/unit/selectmenu/selectmenu_methods.js
@@ -33,21 +33,22 @@ test("enable / disable", function () {
var element = $("#speed").selectmenu();
var widget = element.selectmenu("widget");
var button = widget.filter(".ui-selectmenu-button");
+ var link = button.children("a");
var menu = widget.filter(".ui-selectmenu-menu");
element.selectmenu("disable")
ok( element.selectmenu("option", "disabled"), "disable: widget option" );
equals( button.attr("aria-disabled"), "true", "disable: button wrapper ARIA" );
- equals( button.children("a").attr("aria-disabled"), "true", "disable: button ARIA" );
- equals( button.children("a").attr("tabindex"), -1, "disable: button tabindex" );
+ equals( link.attr("aria-disabled"), "true", "disable: button ARIA" );
+ equals( link.attr("tabindex"), -1, "disable: button tabindex" );
equals( menu.attr("aria-disabled"), "true", "disable: menu wrapper ARIA" );
equals( menu.children("ul").attr("aria-disabled"), "true", "disable: menu ARIA" );
element.selectmenu("enable")
ok( !element.selectmenu("option", "disabled"), "enable: widget option" );
equals( button.attr("aria-disabled"), "false", "enable: button wrapper ARIA" );
- equals( button.children("a").attr("aria-disabled"), "false", "enable: button ARIA" );
- equals( button.children("a").attr("tabindex"), 0, "enable: button tabindex" );
+ equals( link.attr("aria-disabled"), "false", "enable: button ARIA" );
+ equals( link.attr("tabindex"), 0, "enable: button tabindex" );
equals( menu.attr("aria-disabled"), "false", "enable: menu wrapper ARIA" );
equals( menu.children("ul").attr("aria-disabled"), "false", "enable: menu ARIA" );
});
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index b116caa1e..ef56dcd04 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -62,6 +62,10 @@ $.widget( "ui.selectmenu", {
this._bind( this.button, this._buttonEvents );
this._drawMenu();
+
+ if ( this.element.attr( 'disabled' ) ) {
+ this.disable();
+ }
},
_drawButton: function() {
@@ -78,7 +82,6 @@ $.widget( "ui.selectmenu", {
css: {
width: this.element.outerWidth()
},
- 'aria-disabled': this.options.disabled,
'aria-owns': this.ids.menu,
'aria-haspopup': true
})
@@ -391,6 +394,7 @@ $.widget( "ui.selectmenu", {
}
if ( key === "disabled" ) {
this.button.button( "option", "disabled", value );
+ this.menu.menu( "option", "disabled", value );
if ( value ) {
this.element.attr( "disabled", "disabled" );
this.button.attr( "tabindex", -1 );
@@ -399,7 +403,6 @@ $.widget( "ui.selectmenu", {
this.element.removeAttr( "disabled" );
this.button.attr( "tabindex", 0 );
}
- this.menu.attr( "aria-disabled", value );
}
},