MCPcopy
hub / github.com/angular/angular / getExpressionChangedErrorDetails

Function getExpressionChangedErrorDetails

packages/core/src/render3/errors.ts:128–172  ·  view source on GitHub ↗
(
  lView: LView,
  bindingIndex: number,
  oldValue: any,
  newValue: any,
)

Source from the content-addressed store, hash-verified

126 * function description.
127 */
128export function getExpressionChangedErrorDetails(
129 lView: LView,
130 bindingIndex: number,
131 oldValue: any,
132 newValue: any,
133): {propName?: string; oldValue: any; newValue: any} {
134 const tData = lView[TVIEW].data;
135 const metadata = tData[bindingIndex];
136
137 if (typeof metadata === 'string') {
138 // metadata for property interpolation
139 if (metadata.indexOf(INTERPOLATION_DELIMITER) > -1) {
140 return constructDetailsForInterpolation(
141 lView,
142 bindingIndex,
143 bindingIndex,
144 metadata,
145 newValue,
146 );
147 }
148 // metadata for property binding
149 return {propName: metadata, oldValue, newValue};
150 }
151
152 // metadata is not available for this expression, check if this expression is a part of the
153 // property interpolation by going from the current binding index left and look for a string that
154 // contains INTERPOLATION_DELIMITER, the layout in tView.data for this case will look like this:
155 // [..., 'id�Prefix � and � suffix', null, null, null, ...]
156 if (metadata === null) {
157 let idx = bindingIndex - 1;
158 while (typeof tData[idx] !== 'string' && tData[idx + 1] === null) {
159 idx--;
160 }
161 const meta = tData[idx];
162 if (typeof meta === 'string') {
163 const matches = meta.match(new RegExp(INTERPOLATION_DELIMITER, 'g'));
164 // first interpolation delimiter separates property name from interpolation parts (in case of
165 // property interpolations), so we subtract one from total number of found delimiters
166 if (matches && matches.length - 1 > bindingIndex - idx) {
167 return constructDetailsForInterpolation(lView, idx, bindingIndex, meta, newValue);
168 }
169 }
170 }
171 return {propName: undefined, oldValue, newValue};
172}

Callers 1

bindingUpdatedFunction · 0.90

Calls 3

indexOfMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…