diff --git a/lib/deep-equal.js b/lib/deep-equal.js index 4a94191..c4760de 100644 --- a/lib/deep-equal.js +++ b/lib/deep-equal.js @@ -191,6 +191,19 @@ function deepEqualCyclic(actual, expectation, match) { return mapsDeeplyEqual; } + // jQuery objects have iteration protocols + // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols + // But, they don't work well with the implementation concerning iterables below, + // so we will detect them and use jQuery's own equality function + /* istanbul ignore next -- this can only be tested in the `test-headless` script */ + if ( + actualObj.constructor && + actualObj.constructor.name === "jQuery" && + typeof actualObj.is === "function" + ) { + return actualObj.is(expectationObj); + } + var isActualNonArrayIterable = isIterable(actualObj) && !isArrayType(actualObj) &&