@@ -169,17 +169,18 @@ function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
169
169
return predicateFn ;
170
170
}
171
171
172
- function deepCompare ( actual , expected , comparator , matchAgainstAnyProp ) {
172
+ function deepCompare ( actual , expected , comparator , matchAgainstAnyProp , temporaryAnyProp ) {
173
173
var actualType = typeof actual ;
174
174
var expectedType = typeof expected ;
175
+ var nextMatchAgainstAnyProp = matchAgainstAnyProp && ! temporaryAnyProp ;
175
176
176
177
if ( ( expectedType === 'string' ) && ( expected . charAt ( 0 ) === '!' ) ) {
177
- return ! deepCompare ( actual , expected . substring ( 1 ) , comparator , matchAgainstAnyProp ) ;
178
+ return ! deepCompare ( actual , expected . substring ( 1 ) , comparator , nextMatchAgainstAnyProp ) ;
178
179
} else if ( actualType === 'array' ) {
179
180
// In case `actual` is an array, consider it a match
180
181
// if ANY of it's items matches `expected`
181
182
return actual . some ( function ( item ) {
182
- return deepCompare ( item , expected , comparator , matchAgainstAnyProp ) ;
183
+ return deepCompare ( item , expected , comparator , nextMatchAgainstAnyProp ) ;
183
184
} ) ;
184
185
}
185
186
@@ -188,7 +189,7 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp) {
188
189
var key ;
189
190
if ( matchAgainstAnyProp ) {
190
191
for ( key in actual ) {
191
- if ( ( key . charAt ( 0 ) !== '$' ) && deepCompare ( actual [ key ] , expected , comparator ) ) {
192
+ if ( ( key . charAt ( 0 ) !== '$' ) && deepCompare ( actual [ key ] , expected , comparator , nextMatchAgainstAnyProp ) ) {
192
193
return true ;
193
194
}
194
195
}
@@ -202,7 +203,7 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp) {
202
203
203
204
var keyIsDollar = key === '$' ;
204
205
var actualVal = keyIsDollar ? actual : actual [ key ] ;
205
- if ( ! deepCompare ( actualVal , expectedVal , comparator , keyIsDollar ) ) {
206
+ if ( ! deepCompare ( actualVal , expectedVal , comparator , keyIsDollar , keyIsDollar ) ) {
206
207
return false ;
207
208
}
208
209
}
0 commit comments