(lView: LView, bindingIndex: number, value: any)
| 42 | * `CheckNoChangesMode`) |
| 43 | */ |
| 44 | export function bindingUpdated(lView: LView, bindingIndex: number, value: any): boolean { |
| 45 | ngDevMode && |
| 46 | assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`); |
| 47 | |
| 48 | if (value === NO_CHANGE) { |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | const oldValue = lView[bindingIndex]; |
| 53 | |
| 54 | if (Object.is(oldValue, value)) { |
| 55 | return false; |
| 56 | } else { |
| 57 | if (ngDevMode && isInCheckNoChangesMode()) { |
| 58 | // View engine didn't report undefined values as changed on the first checkNoChanges pass |
| 59 | // (before the change detection was run). |
| 60 | const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : undefined; |
| 61 | if (!devModeEqual(oldValueToCompare, value)) { |
| 62 | const details = getExpressionChangedErrorDetails( |
| 63 | lView, |
| 64 | bindingIndex, |
| 65 | oldValueToCompare, |
| 66 | value, |
| 67 | ); |
| 68 | throwErrorIfNoChangesMode( |
| 69 | oldValue === NO_CHANGE, |
| 70 | details.oldValue, |
| 71 | details.newValue, |
| 72 | details.propName, |
| 73 | lView, |
| 74 | ); |
| 75 | } |
| 76 | // There was a change, but the `devModeEqual` decided that the change is exempt from an error. |
| 77 | // For this reason we exit as if no change. The early exit is needed to prevent the changed |
| 78 | // value to be written into `LView` (If we would write the new value that we would not see it |
| 79 | // as change on next CD.) |
| 80 | return false; |
| 81 | } |
| 82 | lView[bindingIndex] = value; |
| 83 | return true; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** Updates 2 bindings if changed, then returns whether either was updated. */ |
| 88 | export function bindingUpdated2(lView: LView, bindingIndex: number, exp1: any, exp2: any): boolean { |
no test coverage detected
searching dependent graphs…