Skip to content

Commit

Permalink
fix(forEach): handle jQuery objects of length 0
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalfaso committed Oct 26, 2015
1 parent 2c8d87e commit dd58cc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ msie = document.documentMode;

function isNodeList(obj) {
return typeof obj.length == 'number' &&
typeof obj.item == 'function';
(typeof obj.item == 'function' ||
isString(obj.jquery));
}

/**
Expand Down
5 changes: 5 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,11 @@ describe('angular', function() {

forEach(jqObject, function(value, key) { log.push(key + ':' + value.innerHTML); });
expect(log).toEqual(['0:s1', '1:s2']);

log = [];
jqObject = jqLite("<pane></pane>");
forEach(jqObject.children(), function(value, key) { log.push(key + ':' + value.innerHTML); });
expect(log).toEqual([]);
});


Expand Down

0 comments on commit dd58cc7

Please sign in to comment.