fix(ivy): refresh child components before executing ViewQuery function (#32922)
Child component refresh must happen before executing the ViewQueryFn because child components could insert a template from the host that contains the result of the ViewQuery function (see related test added in this PR). PR Close #32922
This commit is contained in:
@ -430,17 +430,20 @@ export function refreshView<T>(
|
||||
|
||||
setHostBindings(tView, lView);
|
||||
|
||||
const viewQuery = tView.viewQuery;
|
||||
if (viewQuery !== null) {
|
||||
executeViewQueryFn(RenderFlags.Update, viewQuery, context);
|
||||
}
|
||||
|
||||
// Refresh child component views.
|
||||
const components = tView.components;
|
||||
if (components !== null) {
|
||||
refreshChildComponents(lView, components);
|
||||
}
|
||||
|
||||
// View queries must execute after refreshing child components because a template in this view
|
||||
// could be inserted in a child component. If the view query executes before child component
|
||||
// refresh, the template might not yet be inserted.
|
||||
const viewQuery = tView.viewQuery;
|
||||
if (viewQuery !== null) {
|
||||
executeViewQueryFn(RenderFlags.Update, viewQuery, context);
|
||||
}
|
||||
|
||||
// execute view hooks (AfterViewInit, AfterViewChecked)
|
||||
// PERF WARNING: do NOT extract this to a separate function without running benchmarks
|
||||
if (!checkNoChangesMode) {
|
||||
|
Reference in New Issue
Block a user