(_value)
| 16442 | var oldLength = 0; |
| 16443 | |
| 16444 | function $watchCollectionInterceptor(_value) { |
| 16445 | newValue = _value; |
| 16446 | var newLength, key, bothNaN, newItem, oldItem; |
| 16447 | |
| 16448 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 16449 | if (isUndefined(newValue)) return; |
| 16450 | |
| 16451 | if (!isObject(newValue)) { // if primitive |
| 16452 | if (oldValue !== newValue) { |
| 16453 | oldValue = newValue; |
| 16454 | changeDetected++; |
| 16455 | } |
| 16456 | } else if (isArrayLike(newValue)) { |
| 16457 | if (oldValue !== internalArray) { |
| 16458 | // we are transitioning from something which was not an array into array. |
| 16459 | oldValue = internalArray; |
| 16460 | oldLength = oldValue.length = 0; |
| 16461 | changeDetected++; |
| 16462 | } |
| 16463 | |
| 16464 | newLength = newValue.length; |
| 16465 | |
| 16466 | if (oldLength !== newLength) { |
| 16467 | // if lengths do not match we need to trigger change notification |
| 16468 | changeDetected++; |
| 16469 | oldValue.length = oldLength = newLength; |
| 16470 | } |
| 16471 | // copy the items to oldValue and look for changes. |
| 16472 | for (var i = 0; i < newLength; i++) { |
| 16473 | oldItem = oldValue[i]; |
| 16474 | newItem = newValue[i]; |
| 16475 | |
| 16476 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 16477 | if (!bothNaN && (oldItem !== newItem)) { |
| 16478 | changeDetected++; |
| 16479 | oldValue[i] = newItem; |
| 16480 | } |
| 16481 | } |
| 16482 | } else { |
| 16483 | if (oldValue !== internalObject) { |
| 16484 | // we are transitioning from something which was not an object into object. |
| 16485 | oldValue = internalObject = {}; |
| 16486 | oldLength = 0; |
| 16487 | changeDetected++; |
| 16488 | } |
| 16489 | // copy the items to oldValue and look for changes. |
| 16490 | newLength = 0; |
| 16491 | for (key in newValue) { |
| 16492 | if (hasOwnProperty.call(newValue, key)) { |
| 16493 | newLength++; |
| 16494 | newItem = newValue[key]; |
| 16495 | oldItem = oldValue[key]; |
| 16496 | |
| 16497 | if (key in oldValue) { |
| 16498 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 16499 | if (!bothNaN && (oldItem !== newItem)) { |
| 16500 | changeDetected++; |
| 16501 | oldValue[key] = newItem; |
nothing calls this directly
no test coverage detected