(_value)
| 16006 | var oldLength = 0; |
| 16007 | |
| 16008 | function $watchCollectionInterceptor(_value) { |
| 16009 | newValue = _value; |
| 16010 | var newLength, key, bothNaN, newItem, oldItem; |
| 16011 | |
| 16012 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 16013 | if (isUndefined(newValue)) return; |
| 16014 | |
| 16015 | if (!isObject(newValue)) { // if primitive |
| 16016 | if (oldValue !== newValue) { |
| 16017 | oldValue = newValue; |
| 16018 | changeDetected++; |
| 16019 | } |
| 16020 | } else if (isArrayLike(newValue)) { |
| 16021 | if (oldValue !== internalArray) { |
| 16022 | // we are transitioning from something which was not an array into array. |
| 16023 | oldValue = internalArray; |
| 16024 | oldLength = oldValue.length = 0; |
| 16025 | changeDetected++; |
| 16026 | } |
| 16027 | |
| 16028 | newLength = newValue.length; |
| 16029 | |
| 16030 | if (oldLength !== newLength) { |
| 16031 | // if lengths do not match we need to trigger change notification |
| 16032 | changeDetected++; |
| 16033 | oldValue.length = oldLength = newLength; |
| 16034 | } |
| 16035 | // copy the items to oldValue and look for changes. |
| 16036 | for (var i = 0; i < newLength; i++) { |
| 16037 | oldItem = oldValue[i]; |
| 16038 | newItem = newValue[i]; |
| 16039 | |
| 16040 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 16041 | if (!bothNaN && (oldItem !== newItem)) { |
| 16042 | changeDetected++; |
| 16043 | oldValue[i] = newItem; |
| 16044 | } |
| 16045 | } |
| 16046 | } else { |
| 16047 | if (oldValue !== internalObject) { |
| 16048 | // we are transitioning from something which was not an object into object. |
| 16049 | oldValue = internalObject = {}; |
| 16050 | oldLength = 0; |
| 16051 | changeDetected++; |
| 16052 | } |
| 16053 | // copy the items to oldValue and look for changes. |
| 16054 | newLength = 0; |
| 16055 | for (key in newValue) { |
| 16056 | if (hasOwnProperty.call(newValue, key)) { |
| 16057 | newLength++; |
| 16058 | newItem = newValue[key]; |
| 16059 | oldItem = oldValue[key]; |
| 16060 | |
| 16061 | if (key in oldValue) { |
| 16062 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 16063 | if (!bothNaN && (oldItem !== newItem)) { |
| 16064 | changeDetected++; |
| 16065 | oldValue[key] = newItem; |
nothing calls this directly
no test coverage detected