(_value)
| 18981 | var oldLength = 0; |
| 18982 | |
| 18983 | function $watchCollectionInterceptor(_value) { |
| 18984 | newValue = _value; |
| 18985 | var newLength, key, bothNaN, newItem, oldItem; |
| 18986 | |
| 18987 | // If the new value is undefined, then return undefined as the watch may be a one-time watch |
| 18988 | if (isUndefined(newValue)) return; |
| 18989 | |
| 18990 | if (!isObject(newValue)) { // if primitive |
| 18991 | if (oldValue !== newValue) { |
| 18992 | oldValue = newValue; |
| 18993 | changeDetected++; |
| 18994 | } |
| 18995 | } else if (isArrayLike(newValue)) { |
| 18996 | if (oldValue !== internalArray) { |
| 18997 | // we are transitioning from something which was not an array into array. |
| 18998 | oldValue = internalArray; |
| 18999 | oldLength = oldValue.length = 0; |
| 19000 | changeDetected++; |
| 19001 | } |
| 19002 | |
| 19003 | newLength = newValue.length; |
| 19004 | |
| 19005 | if (oldLength !== newLength) { |
| 19006 | // if lengths do not match we need to trigger change notification |
| 19007 | changeDetected++; |
| 19008 | oldValue.length = oldLength = newLength; |
| 19009 | } |
| 19010 | // copy the items to oldValue and look for changes. |
| 19011 | for (var i = 0; i < newLength; i++) { |
| 19012 | oldItem = oldValue[i]; |
| 19013 | newItem = newValue[i]; |
| 19014 | |
| 19015 | // eslint-disable-next-line no-self-compare |
| 19016 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 19017 | if (!bothNaN && (oldItem !== newItem)) { |
| 19018 | changeDetected++; |
| 19019 | oldValue[i] = newItem; |
| 19020 | } |
| 19021 | } |
| 19022 | } else { |
| 19023 | if (oldValue !== internalObject) { |
| 19024 | // we are transitioning from something which was not an object into object. |
| 19025 | oldValue = internalObject = {}; |
| 19026 | oldLength = 0; |
| 19027 | changeDetected++; |
| 19028 | } |
| 19029 | // copy the items to oldValue and look for changes. |
| 19030 | newLength = 0; |
| 19031 | for (key in newValue) { |
| 19032 | if (hasOwnProperty.call(newValue, key)) { |
| 19033 | newLength++; |
| 19034 | newItem = newValue[key]; |
| 19035 | oldItem = oldValue[key]; |
| 19036 | |
| 19037 | if (key in oldValue) { |
| 19038 | // eslint-disable-next-line no-self-compare |
| 19039 | bothNaN = (oldItem !== oldItem) && (newItem !== newItem); |
| 19040 | if (!bothNaN && (oldItem !== newItem)) { |
nothing calls this directly
no test coverage detected