mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
fix(forEach): allow looping over result of querySelectorAll in IE8
In IE8 the result object of calling `node.querySelectorAll` does not have a `hasOwnPropery` function. However, it should be usable with `forEach`. Related to #5400.
This commit is contained in:
@@ -504,6 +504,21 @@ describe('angular', function() {
|
||||
expect(log).toEqual(['0:a', '1:c']);
|
||||
});
|
||||
|
||||
if (document.querySelectorAll) {
|
||||
it('should handle the result of querySelectorAll in IE8 as it has no hasOwnProperty function', function() {
|
||||
document.body.innerHTML = "<p>" +
|
||||
"<a name='x'>a</a>" +
|
||||
"<a name='y'>b</a>" +
|
||||
"<a name='x'>c</a>" +
|
||||
"</p>";
|
||||
|
||||
var htmlCollection = document.querySelectorAll('[name="x"]'),
|
||||
log = [];
|
||||
|
||||
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML)});
|
||||
expect(log).toEqual(['0:a', '1:c']);
|
||||
});
|
||||
}
|
||||
|
||||
it('should handle arguments objects like arrays', function() {
|
||||
var args,
|
||||
|
||||
Reference in New Issue
Block a user