mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Moved ARIA to input and fixed tests.
This commit is contained in:
parent
e0b52831fc
commit
1dc4d64dd4
@ -27,7 +27,7 @@
|
||||
<body>
|
||||
|
||||
|
||||
<h1 id="qunit-header">jQuery UI Slider Test Suite</h1>
|
||||
<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests">
|
||||
|
@ -150,22 +150,21 @@ test("reading HTML5 attributes", function() {
|
||||
});
|
||||
|
||||
test("ARIA attributes", function() {
|
||||
var el = $('#spin').spinner({ min: -5, max: 5, value: 2 }),
|
||||
wrapper = el.spinner("widget");
|
||||
var el = $('#spin').spinner({ min: -5, max: 5, value: 2 });;
|
||||
|
||||
equals(wrapper.attr('role'), 'spinbutton', 'role');
|
||||
equals(wrapper.attr('aria-valuemin'), -5, 'aria-valuemin');
|
||||
equals(wrapper.attr('aria-valuemax'), 5, 'aria-valuemax');
|
||||
equals(wrapper.attr('aria-valuenow'), 2, 'aria-valuenow');
|
||||
equals(el.attr('role'), 'spinbutton', 'role');
|
||||
equals(el.attr('aria-valuemin'), -5, 'aria-valuemin');
|
||||
equals(el.attr('aria-valuemax'), 5, 'aria-valuemax');
|
||||
equals(el.attr('aria-valuenow'), 2, 'aria-valuenow');
|
||||
|
||||
el.spinner('stepUp');
|
||||
|
||||
equals(wrapper.attr('aria-valuenow'), 3, 'stepUp 1 step changes aria-valuenow');
|
||||
equals(el.attr('aria-valuenow'), 3, 'stepUp 1 step changes aria-valuenow');
|
||||
|
||||
el.spinner('option', { min: -10, max: 10 });
|
||||
|
||||
equals(wrapper.attr('aria-valuemin'), -10, 'min option changed aria-valuemin changes');
|
||||
equals(wrapper.attr('aria-valuemax'), 10, 'max option changed aria-valuemax changes');
|
||||
equals(el.attr('aria-valuemin'), -10, 'min option changed aria-valuemin changes');
|
||||
equals(el.attr('aria-valuemax'), 10, 'max option changed aria-valuemax changes');
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -8,6 +8,7 @@ var spinner_defaults = {
|
||||
max: null,
|
||||
min: null,
|
||||
numberformat: null,
|
||||
page: 10,
|
||||
step: null,
|
||||
value: null
|
||||
};
|
||||
|
9
ui/jquery.ui.spinner.js
vendored
9
ui/jquery.ui.spinner.js
vendored
@ -69,6 +69,7 @@ $.widget('ui.spinner', {
|
||||
});
|
||||
|
||||
this.element
|
||||
.attr( "role", "spinbutton" )
|
||||
.bind('keydown.spinner', function(event) {
|
||||
if (self.options.disabled) {
|
||||
return;
|
||||
@ -198,7 +199,7 @@ $.widget('ui.spinner', {
|
||||
},
|
||||
|
||||
_uiSpinnerHtml: function() {
|
||||
return '<span role="spinbutton" class="ui-spinner ui-state-default ui-widget ui-widget-content ui-corner-all"></span>';
|
||||
return '<span class="ui-spinner ui-state-default ui-widget ui-widget-content ui-corner-all"></span>';
|
||||
},
|
||||
|
||||
_buttonHtml: function() {
|
||||
@ -324,7 +325,11 @@ $.widget('ui.spinner', {
|
||||
this.element
|
||||
.removeClass('ui-spinner-input')
|
||||
.removeAttr('disabled')
|
||||
.removeAttr('autocomplete');
|
||||
.removeAttr('autocomplete')
|
||||
.removeAttr('role')
|
||||
.removeAttr('aria-valuemin')
|
||||
.removeAttr('aria-valuemax')
|
||||
.removeAttr('aria-valuenow');
|
||||
this._super( "destroy" );
|
||||
this.uiSpinner.replaceWith(this.element);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user