From 75515852ea9742d3d84a0f463c2a2c61ef2b7323 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 7 Jan 2014 20:27:45 -0500 Subject: fix(isElement): reduce false-positives in isElement tests Complimentary change to match changed $parse behaviour. --- src/Angular.js | 2 +- test/AngularSpec.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Angular.js b/src/Angular.js index b2905ed9..f1ed847f 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -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 } /** diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 117e8fb0..aa5a5f7b 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -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); + }); }); }); -- cgit v1.2.3