(_value)
| 17610 | var oldLength = 0; |
| 17611 | |
| 17612 | function $watchCollectionInterceptor(_value) { |
| 17613 | newValue = _value; |
| 17614 | var newLength, key, bothNaN, newItem, oldItem; |
| 17615 | |
| 17616 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 17617 | if (isUndefined(newValue)) return; |
| 17618 | |
| 17619 | if (!isObject(newValue)) { // if primitive |
| 17620 | if (oldValue !== newValue) { |
| 17621 | oldValue = newValue; |
| 17622 | changeDetected++; |
| 17623 | } |
| 17624 | } else if (isArrayLike(newValue)) { |
| 17625 | if (oldValue !== internalArray) { |
| 17626 | // we are transitioning from something which was not an array into array. |
| 17627 | oldValue = internalArray; |
| 17628 | oldLength = oldValue.length = 0; |
| 17629 | changeDetected++; |
| 17630 | } |
| 17631 | |
| 17632 | newLength = newValue.length; |
| 17633 | |
| 17634 | if (oldLength !== newLength) { |
| 17635 | // if lengths do not match we need to trigger change notification |
| 17636 | changeDetected++; |
| 17637 | oldValue.length = oldLength = newLength; |
| 17638 | } |
| 17639 | // copy the items to oldValue and look for changes. |
| 17640 | for (var i = 0; i < newLength; i++) { |
| 17641 | oldItem = oldValue[i]; |
| 17642 | newItem = newValue[i]; |
| 17643 | |
| 17644 | // eslint-disable-next-line no-self-compare |
| 17645 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 17646 | if (!bothNaN && (oldItem !== newItem)) { |
| 17647 | changeDetected++; |
| 17648 | oldValue[i] = newItem; |
| 17649 | } |
| 17650 | } |
| 17651 | } else { |
| 17652 | if (oldValue !== internalObject) { |
| 17653 | // we are transitioning from something which was not an object into object. |
| 17654 | oldValue = internalObject = {}; |
| 17655 | oldLength = 0; |
| 17656 | changeDetected++; |
| 17657 | } |
| 17658 | // copy the items to oldValue and look for changes. |
| 17659 | newLength = 0; |
| 17660 | for (key in newValue) { |
| 17661 | if (hasOwnProperty.call(newValue, key)) { |
| 17662 | newLength++; |
| 17663 | newItem = newValue[key]; |
| 17664 | oldItem = oldValue[key]; |
| 17665 | |
| 17666 | if (key in oldValue) { |
| 17667 | // eslint-disable-next-line no-self-compare |
| 17668 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 17669 | if (!bothNaN && (oldItem !== newItem)) { |
nothing calls this directly
no test coverage detected