From a4d134521a21c575c4cf9d32b0b7cba3e20fdcc0 Mon Sep 17 00:00:00 2001 From: slackersoft Date: Sat, 1 Nov 2014 14:28:32 -0700 Subject: [PATCH] Revert "toContain works with array-like objects (Arguments, HTMLCollections, etc)" IE 8 doesn't have Array.prototype.indexOf so this breaks there. Reverting until we can figure out a better way to solve across all supported browsers. This reverts commit 663fbd0cdb48b8bb69c51f5b68620c006290acfa. --- lib/jasmine-core/jasmine.js | 7 +------ spec/core/matchers/matchersUtilSpec.js | 9 --------- src/core/matchers/matchersUtil.js | 7 +------ 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 07e0eabc..2d4f32e8 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2195,12 +2195,7 @@ getJasmineRequireObj().matchersUtil = function(j$) { } return false; } - if (!haystack) { - return false; - } else { - var indexOf = haystack.indexOf || Array.prototype.indexOf; - return indexOf.call(haystack, needle) >= 0; - } + return !!haystack && haystack.indexOf(needle) >= 0; }, buildFailureMessage: function() { diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index f5b7f20c..4a981a13 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -207,15 +207,6 @@ describe("matchersUtil", function() { it("fails when actual is null", function() { expect(j$.matchersUtil.contains(null, 'A')).toBe(false); }); - - it("passes with array-like objects", function() { - var capturedArgs = null; - function testFunction(){ - capturedArgs = arguments; - } - testFunction('foo', 'bar'); - expect(j$.matchersUtil.contains(capturedArgs, 'bar')).toBe(true); - }); }); describe("buildMessage", function() { diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index 488c337b..b6fb8383 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -19,12 +19,7 @@ getJasmineRequireObj().matchersUtil = function(j$) { } return false; } - if (!haystack) { - return false; - } else { - var indexOf = haystack.indexOf || Array.prototype.indexOf; - return indexOf.call(haystack, needle) >= 0; - } + return !!haystack && haystack.indexOf(needle) >= 0; }, buildFailureMessage: function() {