mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(jqLite): special-case attr('class') because of IE9 bug
This commit is contained in:
parent
31b8624121
commit
986608fe76
2 changed files with 16 additions and 1 deletions
|
|
@ -245,7 +245,13 @@ forEach({
|
|||
},
|
||||
|
||||
attr: function(element, name, value){
|
||||
if (SPECIAL_ATTR[name]) {
|
||||
if (name === 'class') {
|
||||
if(isDefined(value)) {
|
||||
element.className = value;
|
||||
} else {
|
||||
return element.className;
|
||||
}
|
||||
} else if (SPECIAL_ATTR[name]) {
|
||||
if (isDefined(value)) {
|
||||
element[name] = !!value;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -168,6 +168,15 @@ describe('jqLite', function(){
|
|||
var elm = jqLite('<div class="any">a</div>');
|
||||
expect(elm.attr('non-existing')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should special-case "class" attribute', function() {
|
||||
// stupid IE9 returns null for element.getAttribute('class') when element has ng:class attr
|
||||
var elm = jqLite('<div class=" any " ng:class="dynCls">a</div>');
|
||||
expect(elm.attr('class')).toBe(' any ');
|
||||
|
||||
elm.attr('class', 'foo bar');
|
||||
expect(elm.attr('class')).toBe('foo bar');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue