toContain works with array-like objects (Arguments, HTMLCollections, etc)
Fixes #699 Don't rely on Array.prototype.indexOf for testing containment (not in IE8)
This commit is contained in:
committed by
slackersoft
parent
a4d134521a
commit
da6813ef0d
@@ -11,7 +11,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
contains: function(haystack, needle, customTesters) {
|
||||
customTesters = customTesters || [];
|
||||
|
||||
if (Object.prototype.toString.apply(haystack) === '[object Array]') {
|
||||
if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
|
||||
(!!haystack && !haystack.indexOf))
|
||||
{
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
if (eq(haystack[i], needle, [], [], customTesters)) {
|
||||
return true;
|
||||
@@ -19,6 +21,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!haystack && haystack.indexOf(needle) >= 0;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user