Core: Reduced size of ARIA methods.

This commit is contained in:
Scott González 2008-09-23 00:11:26 +00:00
parent dd7511c4f9
commit 78a2337faf

View File

@ -97,26 +97,29 @@ $.keyCode = {
// WAI-ARIA Semantics // WAI-ARIA Semantics
var isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); var isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
$.fn.extend({ $.fn.extend({
ariaRole : function(role) { ariaRole: function(role) {
// setter? return (role !== undefined
if (role) {
return this.each(function(i, el) { // setter
$(el).attr("role", isFF2 ? "wairole:" + role : role); ? this.attr("role", isFF2 ? "wairole:" + role : role)
});
} // getter
// getter just returns first jquery member's role string : (this.attr("role") || "").replace(/^wairole:/, ""));
return (this.eq(0).attr("role") || "").replace(/^wairole:/, "");
}, },
ariaState : function(state, value) { ariaState: function(state, value) {
// setter? return (value !== undefined
if (value !== undefined)
return this.each(function(i, el) { // setter
isFF2? el.setAttributeNS("http://www.w3.org/2005/07/aaa", "aaa:" + state, value) : ? this.each(function(i, el) {
$(el).attr("aria-" + state, value); (isFF2
}); ? el.setAttributeNS("http://www.w3.org/2005/07/aaa",
// getter "aaa:" + state, value)
return this.attr(isFF2? "aaa:"+state : "aria-" + state); : $(el).attr("aria-" + state, value));
})
// getter
: this.attr(isFF2 ? "aaa:" + state : "aria-" + state));
} }
}); });