mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: Fixed #3562: Modify .removeAttr() to work on ARIA properties in FF2.
This commit is contained in:
parent
0808041ad9
commit
6fb3ffad36
@ -56,12 +56,23 @@ test("tabbable - tabindex", function() {
|
||||
module('jQuery extensions');
|
||||
|
||||
test("attr - aria", function() {
|
||||
expect(4);
|
||||
expect(6);
|
||||
|
||||
ok(!$('#aria').attr('role'), 'role is empty via attr');
|
||||
equals($('#aria').attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist');
|
||||
equals($('#aria').attr('aria-expanded', true).attr('aria-expanded'), 'true', 'aria expanded is true');
|
||||
equals($('#aria').attr('aria-expanded', false).attr('aria-expanded'), 'false', 'aria expanded is false');
|
||||
var el = $('#aria');
|
||||
|
||||
ok(!el.attr('role'), 'role is empty via attr');
|
||||
equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist');
|
||||
|
||||
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined');
|
||||
|
||||
el.attr('aria-expanded', true);
|
||||
equals(el.attr('aria-expanded'), 'true', 'aria expanded is true');
|
||||
|
||||
el.removeAttr('aria-expanded');
|
||||
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing');
|
||||
|
||||
el.attr('aria-expanded', false);
|
||||
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -135,9 +135,10 @@ $.ui = {
|
||||
};
|
||||
|
||||
// WAI-ARIA normalization
|
||||
// tweak $.attr for FF2 implementation
|
||||
if (isFF2) {
|
||||
var attr = $.attr,
|
||||
removeAttr = $.fn.removeAttr,
|
||||
ariaNS = "http://www.w3.org/2005/07/aaa",
|
||||
ariaState = /^aria-/,
|
||||
ariaRole = /^wairole:/;
|
||||
|
||||
@ -150,11 +151,18 @@ if (isFF2) {
|
||||
: (attr.apply(this, arguments) || "").replace(ariaRole, ""))
|
||||
: (ariaState.test(name)
|
||||
? (set
|
||||
? elem.setAttributeNS("http://www.w3.org/2005/07/aaa",
|
||||
? elem.setAttributeNS(ariaNS,
|
||||
name.replace(ariaState, "aaa:"), value)
|
||||
: attr.call(this, elem, name.replace(ariaState, "aaa:")))
|
||||
: attr.apply(this, arguments)));
|
||||
};
|
||||
|
||||
$.fn.removeAttr = function(name) {
|
||||
return (ariaState.test(name)
|
||||
? this.each(function() {
|
||||
this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
|
||||
}) : removeAttr.call(this, name));
|
||||
};
|
||||
}
|
||||
|
||||
//jQuery plugins
|
||||
|
Loading…
Reference in New Issue
Block a user