(_value)
| 18316 | var oldLength = 0; |
| 18317 | |
| 18318 | function $watchCollectionInterceptor(_value) { |
| 18319 | newValue = _value; |
| 18320 | var newLength, key, bothNaN, newItem, oldItem; |
| 18321 | |
| 18322 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 18323 | if (isUndefined(newValue)) return; |
| 18324 | |
| 18325 | if (!isObject(newValue)) { // if primitive |
| 18326 | if (oldValue !== newValue) { |
| 18327 | oldValue = newValue; |
| 18328 | changeDetected++; |
| 18329 | } |
| 18330 | } else if (isArrayLike(newValue)) { |
| 18331 | if (oldValue !== internalArray) { |
| 18332 | // we are transitioning from something which was not an array into array. |
| 18333 | oldValue = internalArray; |
| 18334 | oldLength = oldValue.length = 0; |
| 18335 | changeDetected++; |
| 18336 | } |
| 18337 | |
| 18338 | newLength = newValue.length; |
| 18339 | |
| 18340 | if (oldLength !== newLength) { |
| 18341 | // if lengths do not match we need to trigger change notification |
| 18342 | changeDetected++; |
| 18343 | oldValue.length = oldLength = newLength; |
| 18344 | } |
| 18345 | // copy the items to oldValue and look for changes. |
| 18346 | for (var i = 0; i < newLength; i++) { |
| 18347 | oldItem = oldValue[i]; |
| 18348 | newItem = newValue[i]; |
| 18349 | |
| 18350 | // eslint-disable-next-line no-self-compare |
| 18351 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 18352 | if (!bothNaN && (oldItem !== newItem)) { |
| 18353 | changeDetected++; |
| 18354 | oldValue[i] = newItem; |
| 18355 | } |
| 18356 | } |
| 18357 | } else { |
| 18358 | if (oldValue !== internalObject) { |
| 18359 | // we are transitioning from something which was not an object into object. |
| 18360 | oldValue = internalObject = {}; |
| 18361 | oldLength = 0; |
| 18362 | changeDetected++; |
| 18363 | } |
| 18364 | // copy the items to oldValue and look for changes. |
| 18365 | newLength = 0; |
| 18366 | for (key in newValue) { |
| 18367 | if (hasOwnProperty.call(newValue, key)) { |
| 18368 | newLength++; |
| 18369 | newItem = newValue[key]; |
| 18370 | oldItem = oldValue[key]; |
| 18371 | |
| 18372 | if (key in oldValue) { |
| 18373 | // eslint-disable-next-line no-self-compare |
| 18374 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 18375 | if (!bothNaN && (oldItem !== newItem)) { |
nothing calls this directly
no test coverage detected