MCPcopy Index your code
hub / github.com/angular/angular / applyUpdateOpCodes

Function applyUpdateOpCodes

packages/core/src/render3/i18n/i18n_apply.ts:402–494  ·  view source on GitHub ↗

* Apply `I18nUpdateOpCodes` OpCodes * * @param tView Current `TView` * @param lView Current `LView` * @param updateOpCodes OpCodes to process * @param bindingsStartIndex Location of the first `ɵɵi18nApply` * @param changeMask Each bit corresponds to a `ɵɵi18nExp` (Counting backwards from *

(
  tView: TView,
  lView: LView,
  updateOpCodes: I18nUpdateOpCodes,
  bindingsStartIndex: number,
  changeMask: number,
)

Source from the content-addressed store, hash-verified

400 * `bindingsStartIndex`)
401 */
402function applyUpdateOpCodes(
403 tView: TView,
404 lView: LView,
405 updateOpCodes: I18nUpdateOpCodes,
406 bindingsStartIndex: number,
407 changeMask: number,
408) {
409 for (let i = 0; i < updateOpCodes.length; i++) {
410 // bit code to check if we should apply the next update
411 const checkBit = updateOpCodes[i] as number;
412 // Number of opCodes to skip until next set of update codes
413 const skipCodes = updateOpCodes[++i] as number;
414 if (checkBit & changeMask) {
415 // The value has been updated since last checked
416 let value = '';
417 for (let j = i + 1; j <= i + skipCodes; j++) {
418 const opCode = updateOpCodes[j];
419 if (typeof opCode == 'string') {
420 value += opCode;
421 } else if (typeof opCode == 'number') {
422 if (opCode < 0) {
423 // Negative opCode represent `i18nExp` values offset.
424 value += renderStringify(lView[bindingsStartIndex - opCode]);
425 } else {
426 const nodeIndex = opCode >>> I18nUpdateOpCode.SHIFT_REF;
427 switch (opCode & I18nUpdateOpCode.MASK_OPCODE) {
428 case I18nUpdateOpCode.Attr:
429 const propName = updateOpCodes[++j] as string;
430 const sanitizeFn = updateOpCodes[++j] as SanitizerFn | null;
431 const tNodeOrTagName = tView.data[nodeIndex] as TNode | string;
432 ngDevMode && assertDefined(tNodeOrTagName, 'Experting TNode or string');
433 if (typeof tNodeOrTagName === 'string') {
434 // IF we don't have a `TNode`, then we are an element in ICU (as ICU content does
435 // not have TNode), in which case we know that there are no directives, and hence
436 // we use attribute setting.
437 setElementAttribute(
438 lView[RENDERER],
439 lView[nodeIndex],
440 null,
441 tNodeOrTagName,
442 propName,
443 value,
444 sanitizeFn,
445 );
446 } else {
447 const prevSelectedIndex = getSelectedIndex();
448 setSelectedIndex(nodeIndex);
449 try {
450 setPropertyAndInputs(
451 tNodeOrTagName,
452 lView,
453 propName,
454 value,
455 lView[RENDERER],
456 sanitizeFn,
457 );
458 } finally {
459 setSelectedIndex(prevSelectedIndex);

Callers 2

applyI18nFunction · 0.85
applyIcuUpdateCaseFunction · 0.85

Calls 10

renderStringifyFunction · 0.90
assertDefinedFunction · 0.90
setElementAttributeFunction · 0.90
getSelectedIndexFunction · 0.90
setSelectedIndexFunction · 0.90
setPropertyAndInputsFunction · 0.90
updateTextNodeFunction · 0.90
getTIcuFunction · 0.90
applyIcuSwitchCaseFunction · 0.85
applyIcuUpdateCaseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…