(_value)
| 15463 | var oldLength = 0; |
| 15464 | |
| 15465 | function $watchCollectionInterceptor(_value) { |
| 15466 | newValue = _value; |
| 15467 | var newLength, key, bothNaN, newItem, oldItem; |
| 15468 | |
| 15469 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 15470 | if (isUndefined(newValue)) return; |
| 15471 | |
| 15472 | if (!isObject(newValue)) { // if primitive |
| 15473 | if (oldValue !== newValue) { |
| 15474 | oldValue = newValue; |
| 15475 | changeDetected++; |
| 15476 | } |
| 15477 | } else if (isArrayLike(newValue)) { |
| 15478 | if (oldValue !== internalArray) { |
| 15479 | // we are transitioning from something which was not an array into array. |
| 15480 | oldValue = internalArray; |
| 15481 | oldLength = oldValue.length = 0; |
| 15482 | changeDetected++; |
| 15483 | } |
| 15484 | |
| 15485 | newLength = newValue.length; |
| 15486 | |
| 15487 | if (oldLength !== newLength) { |
| 15488 | // if lengths do not match we need to trigger change notification |
| 15489 | changeDetected++; |
| 15490 | oldValue.length = oldLength = newLength; |
| 15491 | } |
| 15492 | // copy the items to oldValue and look for changes. |
| 15493 | for (var i = 0; i < newLength; i++) { |
| 15494 | oldItem = oldValue[i]; |
| 15495 | newItem = newValue[i]; |
| 15496 | |
| 15497 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 15498 | if (!bothNaN && (oldItem !== newItem)) { |
| 15499 | changeDetected++; |
| 15500 | oldValue[i] = newItem; |
| 15501 | } |
| 15502 | } |
| 15503 | } else { |
| 15504 | if (oldValue !== internalObject) { |
| 15505 | // we are transitioning from something which was not an object into object. |
| 15506 | oldValue = internalObject = {}; |
| 15507 | oldLength = 0; |
| 15508 | changeDetected++; |
| 15509 | } |
| 15510 | // copy the items to oldValue and look for changes. |
| 15511 | newLength = 0; |
| 15512 | for (key in newValue) { |
| 15513 | if (newValue.hasOwnProperty(key)) { |
| 15514 | newLength++; |
| 15515 | newItem = newValue[key]; |
| 15516 | oldItem = oldValue[key]; |
| 15517 | |
| 15518 | if (key in oldValue) { |
| 15519 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 15520 | if (!bothNaN && (oldItem !== newItem)) { |
| 15521 | changeDetected++; |
| 15522 | oldValue[key] = newItem; |
nothing calls this directly
no test coverage detected