mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix:jqLite: Normalize non-existing attributes to undefined as jQuery
jqLite was returning null, but jQuery returns undefined
This commit is contained in:
parent
9ee9ca13da
commit
10da625ed9
2 changed files with 7 additions and 1 deletions
|
|
@ -266,7 +266,9 @@ forEach({
|
|||
} else if (element.getAttribute) {
|
||||
// the extra argument "2" is to get the right thing for a.href in IE, see jQuery code
|
||||
// some elements (e.g. Document) don't have get attribute, so return undefined
|
||||
return element.getAttribute(name, 2);
|
||||
var ret = element.getAttribute(name, 2);
|
||||
// normalize non-existing attributes to undefined (as jQuery)
|
||||
return ret === null ? undefined : ret;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,10 @@ describe('jqLite', function(){
|
|||
expect(select.attr('multiple')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should return undefined for non-existing attributes', function() {
|
||||
var elm = jqLite('<div class="any">a</div>');
|
||||
expect(elm.attr('non-existing')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue