Changeset 941

Show
Ignore:
Timestamp:
11/14/08 20:29:08 (16 months ago)
Author:
scott.gonzalez
Message:

Core: Fixed #3562: Modify .removeAttr() to work on ARIA properties in FF2.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/core.js

    r930 r941  
    5757 
    5858test("attr - aria", function() { 
    59         expect(4); 
     59        expect(6); 
    6060         
    61         ok(!$('#aria').attr('role'), 'role is empty via attr'); 
    62         equals($('#aria').attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist'); 
    63         equals($('#aria').attr('aria-expanded', true).attr('aria-expanded'), 'true', 'aria expanded is true'); 
    64         equals($('#aria').attr('aria-expanded', false).attr('aria-expanded'), 'false', 'aria expanded is false'); 
     61        var el = $('#aria'); 
     62         
     63        ok(!el.attr('role'), 'role is empty via attr'); 
     64        equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist'); 
     65         
     66        equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined'); 
     67         
     68        el.attr('aria-expanded', true); 
     69        equals(el.attr('aria-expanded'), 'true', 'aria expanded is true'); 
     70         
     71        el.removeAttr('aria-expanded'); 
     72        equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing'); 
     73         
     74        el.attr('aria-expanded', false); 
     75        equals(el.attr('aria-expanded'), 'false', 'aria expanded is false'); 
    6576}); 
    6677 
  • trunk/ui/ui.core.js

    r933 r941  
    136136 
    137137// WAI-ARIA normalization 
    138 // tweak $.attr for FF2 implementation 
    139138if (isFF2) { 
    140139        var attr = $.attr, 
     140                removeAttr = $.fn.removeAttr, 
     141                ariaNS = "http://www.w3.org/2005/07/aaa", 
    141142                ariaState = /^aria-/, 
    142143                ariaRole = /^wairole:/; 
     
    151152                        : (ariaState.test(name) 
    152153                                ? (set 
    153                                         ? elem.setAttributeNS("http://www.w3.org/2005/07/aaa", 
     154                                        ? elem.setAttributeNS(ariaNS, 
    154155                                                name.replace(ariaState, "aaa:"), value) 
    155156                                        : attr.call(this, elem, name.replace(ariaState, "aaa:"))) 
    156157                                : attr.apply(this, arguments))); 
     158        }; 
     159         
     160        $.fn.removeAttr = function(name) { 
     161                return (ariaState.test(name) 
     162                        ? this.each(function() { 
     163                                this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); 
     164                        }) : removeAttr.call(this, name)); 
    157165        }; 
    158166}