MCPcopy Create free account
hub / github.com/angular/angular / ɵɵboundaryUpdate

Function ɵɵboundaryUpdate

packages/core/src/render3/instructions/boundary.ts:82–206  ·  view source on GitHub ↗
(
  slotIndex: number,
  matchingTemplateIndex: number,
  primaryTemplateIndex: number,
)

Source from the content-addressed store, hash-verified

80 * logic into a shared utility function to reduce duplication.
81 */
82export function ɵɵboundaryUpdate(
83 slotIndex: number,
84 matchingTemplateIndex: number,
85 primaryTemplateIndex: number,
86) {
87 const hostLView = getLView();
88 const bindingIndex = nextBindingIndex();
89 const prevMatchingTemplateIndex: number =
90 hostLView[bindingIndex] !== NO_CHANGE ? hostLView[bindingIndex] : -1;
91 const prevContainer =
92 prevMatchingTemplateIndex !== -1
93 ? getLContainer(hostLView, HEADER_OFFSET + prevMatchingTemplateIndex)
94 : undefined;
95 const viewInContainerIdx = 0;
96
97 if (bindingUpdated(hostLView, bindingIndex, matchingTemplateIndex)) {
98 const prevConsumer = setActiveConsumer(null);
99 try {
100 if (prevContainer !== undefined) {
101 removeLViewFromLContainer(prevContainer, viewInContainerIdx);
102 }
103
104 if (matchingTemplateIndex !== -1) {
105 const nextLContainerIndex = HEADER_OFFSET + matchingTemplateIndex;
106 const nextContainer = getLContainer(hostLView, nextLContainerIndex);
107 const templateTNode = getExistingTNode(hostLView[TVIEW], nextLContainerIndex);
108
109 const dehydratedView = findAndReconcileMatchingDehydratedViews(
110 nextContainer,
111 templateTNode,
112 hostLView,
113 );
114
115 let embeddedLView: LView<any> | undefined;
116 try {
117 const boundary = hostLView[HEADER_OFFSET + slotIndex] as LBoundary;
118 const context =
119 matchingTemplateIndex === primaryTemplateIndex
120 ? undefined
121 : {$error: boundary.error, $reset: createBoundaryResetFn(boundary)};
122 embeddedLView = createAndRenderEmbeddedLView(hostLView, templateTNode, context, {
123 dehydratedView,
124 });
125
126 if (matchingTemplateIndex === primaryTemplateIndex) {
127 embeddedLView[ON_ERROR] = (error: Error, details: ErrorDetails) => {
128 const boundary = hostLView[HEADER_OFFSET + slotIndex] as LBoundary;
129 boundary.error = error;
130
131 const errorHandler = hostLView[INJECTOR]?.get(ErrorHandler, null);
132 if (errorHandler) {
133 const boundaryComponentView = hostLView[DECLARATION_COMPONENT_VIEW][CONTEXT] as any;
134 const boundaryType: Type<unknown> = boundaryComponentView.constructor;
135 (details as Writable<ErrorDetails>).boundary = {
136 type: boundaryType,
137 reset: createBoundaryResetFn(boundary),
138 };
139

Callers

nothing calls this directly

Calls 15

getLViewFunction · 0.90
nextBindingIndexFunction · 0.90
getLContainerFunction · 0.90
bindingUpdatedFunction · 0.90
setActiveConsumerFunction · 0.90
getExistingTNodeFunction · 0.90
markViewForRefreshFunction · 0.90
encapsulateBoundaryErrorFunction · 0.90
addLViewToLContainerFunction · 0.90

Tested by

no test coverage detected