### Eclipse Workspace Patch 1.0 #P jQuery Index: tests/unit/slider/slider_core.js =================================================================== --- tests/unit/slider/slider_core.js (revision 2920) +++ tests/unit/slider/slider_core.js (working copy) @@ -243,4 +243,84 @@ el.slider("destroy"); }); +test("ARIA Min and Max", function() { + el = $('
'); + + options = { + max: 54, + min: 3, + orientation: 'horizontal', + value:15 + }; + + el.slider(options); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 54, "The ARIA-valuemax should be 54" ); + equals(handles.attr("aria-valuemin"), 3, "The ARIA-valuemin should be 3" ); + equals(handles.attr("aria-valuenow"), 15, "The ARIA-valuenow should be 15" ); + el.slider('destroy'); +}); + +test("ARIA Min and Max with default options", function() { + el = $(''); + + el.slider(); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 100, "The ARIA max should be 100" ); + equals(handles.attr("aria-valuemin"), 0, "The ARIA min should be 0" ); + equals(handles.attr("aria-valuenow"), 0, "The ARIA-valuenow should be 0" ); + el.slider('destroy'); +}); + +test("ARIA-valuenow after keydown LEFT", function(){ + el = $(''); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 4 + }; + el.slider(options); + var handles = handle(); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(handles.attr("aria-valuenow"), 3, "The ARIA-valuenow should be 3" ); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(handles.attr("aria-valuenow"), 2, "The ARIA-valuenow should be 2" ); + + el.slider("destroy"); + +}); + +test("ARIA-valuenow after keydown RIGHT", function(){ + el = $(''); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 2 + }; + el.slider(options); + var handles = handle(); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 3, "The ARIA-valuenow should be 3" ); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 4, "The ARIA-valuenow should be 4" ); + + el.slider("destroy"); + +}); + + })(jQuery); Index: ui/ui.slider.js =================================================================== --- ui/ui.slider.js (revision 2920) +++ ui/ui.slider.js (working copy) @@ -59,13 +59,13 @@ } if ($(".ui-slider-handle", this.element).length == 0) - $('') - .appendTo(this.element) + $('') + .appendTo(this.element) .addClass("ui-slider-handle"); if (o.values && o.values.length) { while ($(".ui-slider-handle", this.element).length < o.values.length) - $('') + $('') .appendTo(this.element) .addClass("ui-slider-handle"); } @@ -170,6 +170,13 @@ }); + var ariaDefaults = {role: 'slider', + "aria-valuenow": this.options.value, + "aria-valuemin": this.options.min, + "aria-valuemax": this.options.max + }; + this.handles.attr(ariaDefaults); + this._refreshValue(); }, @@ -469,6 +476,8 @@ if (val < this._valueMin()) val = this._valueMin(); if (val > this._valueMax()) val = this._valueMax(); + this.handles.attr("aria-valuenow",val); + //console.log($(this.handles).attr("aria-valuenow")); return val; },