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

Commit 7551585

Browse files
committed
fix(isElement): reduce false-positives in isElement tests
Complimentary change to match changed $parse behaviour.
1 parent 5fe1f39 commit 7551585

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ var trim = (function() {
601601
function isElement(node) {
602602
return !!(node &&
603603
(node.nodeName // we are a direct element
604-
|| (node.on && node.find))); // we have an on and find method part of jQuery API
604+
|| (node.prop && node.attr && node.find))); // we have an on and find method part of jQuery API
605605
}
606606

607607
/**

test/AngularSpec.js

+20
Original file line numberDiff line numberDiff line change
@@ -1127,5 +1127,25 @@ describe('angular', function() {
11271127
expect(result).toEqual(expected[idx]);
11281128
});
11291129
}));
1130+
1131+
// Issue #4805
1132+
it('should return false for objects resembling a Backbone Collection', function() {
1133+
// Backbone stuff is sort of hard to mock, if you have a better way of doing this,
1134+
// please fix this.
1135+
var fakeBackboneCollection = {
1136+
children: [{}, {}, {}],
1137+
find: function() {},
1138+
on: function() {},
1139+
off: function() {},
1140+
bind: function() {}
1141+
};
1142+
expect(isElement(fakeBackboneCollection)).toBe(false);
1143+
});
1144+
1145+
it('should return false for arrays with node-like properties', function() {
1146+
var array = [1,2,3];
1147+
array.on = true;
1148+
expect(isElement(array)).toBe(false);
1149+
});
11301150
});
11311151
});

0 commit comments

Comments
 (0)