Button: Let change handler handle display and aria update. Fixed #5518 - Button: Incorrect state after double click in Firefox

This commit is contained in:
Fabrício Matté 2012-11-26 20:14:58 -05:00 committed by Mike Sherov
parent 0cc81978b2
commit caacf8f504
3 changed files with 12 additions and 2 deletions

View File

@ -68,6 +68,7 @@
</form>
<input type="checkbox" id="check"><label for="check">Toggle</label>
<input type="checkbox" id="check2"><label for="check2">Checkbox</label>
<div><input id="submit" type="submit" value="Label"></div>

View File

@ -23,4 +23,15 @@ test( "when button loses focus, ensure active state is removed (#8559)", functio
}).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
});
test( "ensure checked and aria after single click on checkbox label button", function() {
expect( 3 );
$("#check2").button().change( function() {
var lbl = $( this ).button("widget");
ok( this.checked, "checked ok" );
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
ok( lbl.hasClass("ui-state-active"), "ui-state-active ok" );
}).button("widget").simulate("click");
});
})(jQuery);

View File

@ -147,8 +147,6 @@ $.widget( "ui.button", {
if ( options.disabled || clickDragged ) {
return false;
}
$( this ).toggleClass( "ui-state-active" );
that.buttonElement.attr( "aria-pressed", that.element[0].checked );
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {