@@ -169,17 +169,18 @@ function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
169169 return predicateFn ;
170170}
171171
172- function deepCompare ( actual , expected , comparator , matchAgainstAnyProp ) {
172+ function deepCompare ( actual , expected , comparator , matchAgainstAnyProp , temporaryAnyProp ) {
173173 var actualType = typeof actual ;
174174 var expectedType = typeof expected ;
175+ var nextMatchAgainstAnyProp = matchAgainstAnyProp && ! temporaryAnyProp ;
175176
176177 if ( ( expectedType === 'string' ) && ( expected . charAt ( 0 ) === '!' ) ) {
177- return ! deepCompare ( actual , expected . substring ( 1 ) , comparator , matchAgainstAnyProp ) ;
178+ return ! deepCompare ( actual , expected . substring ( 1 ) , comparator , nextMatchAgainstAnyProp ) ;
178179 } else if ( actualType === 'array' ) {
179180 // In case `actual` is an array, consider it a match
180181 // if ANY of it's items matches `expected`
181182 return actual . some ( function ( item ) {
182- return deepCompare ( item , expected , comparator , matchAgainstAnyProp ) ;
183+ return deepCompare ( item , expected , comparator , nextMatchAgainstAnyProp ) ;
183184 } ) ;
184185 }
185186
@@ -188,7 +189,7 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp) {
188189 var key ;
189190 if ( matchAgainstAnyProp ) {
190191 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 ) ) {
192193 return true ;
193194 }
194195 }
@@ -202,7 +203,7 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp) {
202203
203204 var keyIsDollar = key === '$' ;
204205 var actualVal = keyIsDollar ? actual : actual [ key ] ;
205- if ( ! deepCompare ( actualVal , expectedVal , comparator , keyIsDollar ) ) {
206+ if ( ! deepCompare ( actualVal , expectedVal , comparator , keyIsDollar , keyIsDollar ) ) {
206207 return false ;
207208 }
208209 }
0 commit comments