Skip to content

Commit

Permalink
refactor(core): Simplify detectChangesInternal call signature (angula…
Browse files Browse the repository at this point in the history
…r#52866)

The call signature of detectChangesInternal requires parameters that can all be
found directly on lView. This commit removes those paramters and instead
grabs them in the function implementation.

PR Close angular#52866
  • Loading branch information
atscott authored and thePunderWoman committed Nov 14, 2023
1 parent 3f09406 commit 7f9ab9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/render3/instructions/change_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import {executeTemplate, executeViewQueryFn, handleError, processHostBindingOpCo
*/
const MAXIMUM_REFRESH_RERUNS = 100;

export function detectChangesInternal<T>(
tView: TView, lView: LView, context: T, notifyErrorHandler = true) {
export function detectChangesInternal(lView: LView, notifyErrorHandler = true) {
const environment = lView[ENVIRONMENT];
const rendererFactory = environment.rendererFactory;
const afterRenderEventManager = environment.afterRenderEventManager;
Expand All @@ -45,6 +44,8 @@ export function detectChangesInternal<T>(
}

try {
const tView = lView[TVIEW];
const context = lView[CONTEXT];
refreshView(tView, lView, tView.template, context);
detectChangesInViewWhileDirty(lView);
} catch (error) {
Expand Down Expand Up @@ -89,11 +90,10 @@ function detectChangesInViewWhileDirty(lView: LView) {
}
}

export function checkNoChangesInternal<T>(
tView: TView, lView: LView, context: T, notifyErrorHandler = true) {
export function checkNoChangesInternal(lView: LView, notifyErrorHandler = true) {
setIsInCheckNoChangesMode(true);
try {
detectChangesInternal(tView, lView, context, notifyErrorHandler);
detectChangesInternal(lView, notifyErrorHandler);
} finally {
setIsInCheckNoChangesMode(false);
}
Expand All @@ -108,7 +108,7 @@ export function checkNoChangesInternal<T>(
*/
export function detectChanges(component: {}): void {
const view = getComponentViewByInstance(component);
detectChangesInternal(view[TVIEW], view, component);
detectChangesInternal(view);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/render3/view_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ export class ViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRefInterfac
* See {@link ChangeDetectorRef#detach} for more information.
*/
detectChanges(): void {
detectChangesInternal(
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
detectChangesInternal(this._lView, this.notifyErrorHandler);
}

/**
Expand All @@ -296,8 +295,7 @@ export class ViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorRefInterfac
*/
checkNoChanges(): void {
if (ngDevMode) {
checkNoChangesInternal(
this._lView[TVIEW], this._lView, this.context as unknown as {}, this.notifyErrorHandler);
checkNoChangesInternal(this._lView, this.notifyErrorHandler);
}
}

Expand Down

0 comments on commit 7f9ab9d

Please sign in to comment.