Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(isElement): reduce false-positives in isElement tests
Browse files Browse the repository at this point in the history
Complimentary change to match changed $parse behaviour.
  • Loading branch information
caitp committed Feb 21, 2014
1 parent 5fe1f39 commit 7551585
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ var trim = (function() {
function isElement(node) {
return !!(node &&
(node.nodeName // we are a direct element
|| (node.on && node.find))); // we have an on and find method part of jQuery API
|| (node.prop && node.attr && node.find))); // we have an on and find method part of jQuery API
}

/**
Expand Down
20 changes: 20 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,5 +1127,25 @@ describe('angular', function() {
expect(result).toEqual(expected[idx]);
});
}));

// Issue #4805
it('should return false for objects resembling a Backbone Collection', function() {
// Backbone stuff is sort of hard to mock, if you have a better way of doing this,
// please fix this.
var fakeBackboneCollection = {
children: [{}, {}, {}],
find: function() {},
on: function() {},
off: function() {},
bind: function() {}
};
expect(isElement(fakeBackboneCollection)).toBe(false);
});

it('should return false for arrays with node-like properties', function() {
var array = [1,2,3];
array.on = true;
expect(isElement(array)).toBe(false);
});
});
});

0 comments on commit 7551585

Please sign in to comment.