Skip to content

feat(core): Set default Component changeDetection strategy to OnPush#67687

Merged
leonsenft merged 1 commit intoangular:mainfrom
JeanMeche:onpush-default
Mar 24, 2026
Merged

feat(core): Set default Component changeDetection strategy to OnPush#67687
leonsenft merged 1 commit intoangular:mainfrom
JeanMeche:onpush-default

Conversation

@JeanMeche
Copy link
Member

The default change detection strategy is now OnPush.

BREAKING CHANGE: Component with undefined changeDetection property are now OnPush by default. Specify changeDetection: ChangeDetectionStrategy.Eager to keep the previous behavior.

@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Mar 13, 2026
@JeanMeche JeanMeche added state: blocked on G3 cleanup This change requires a G3 cleanup and removed area: core Issues related to the framework runtime detected: feature PR contains a feature commit detected: breaking change PR contains a commit with a breaking change labels Mar 13, 2026
@ngbot ngbot bot modified the milestone: Backlog Mar 13, 2026
@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Mar 13, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 13, 2026
@JeanMeche JeanMeche force-pushed the onpush-default branch 14 times, most recently from a4939c4 to 2cab6fa Compare March 16, 2026 09:18
@JeanMeche JeanMeche force-pushed the onpush-default branch 3 times, most recently from 59ed1bb to 2dd64a6 Compare March 16, 2026 11:11
@JeanMeche JeanMeche added the target: major This PR is targeted for the next major release label Mar 16, 2026
@JeanMeche JeanMeche force-pushed the onpush-default branch 2 times, most recently from c6d76e2 to c42c696 Compare March 21, 2026 01:48
@JeanMeche JeanMeche marked this pull request as ready for review March 23, 2026 02:21
@JeanMeche JeanMeche requested a review from atscott March 23, 2026 02:22
@JeanMeche JeanMeche removed the state: blocked on G3 cleanup This change requires a G3 cleanup label Mar 23, 2026
if (
typeof meta.changeDetection === 'number' &&
meta.changeDetection !== core.ChangeDetectionStrategy.Default
meta.changeDetection !== core.ChangeDetectionStrategy.OnPush
Copy link
Member Author

@JeanMeche JeanMeche Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm highlighting the main changes
1.

Comment on lines 107 to +249
@@ -242,7 +244,9 @@ export class PartialComponentLinkerVersion1<TStatement, TExpression>
: ViewEncapsulation.Emulated,
changeDetection: metaObj.has('changeDetection')
? parseChangeDetectionStrategy(metaObj.getValue('changeDetection'))
: ChangeDetectionStrategy.Default,
: hasOnPushByDefault
? ChangeDetectionStrategy.OnPush
: ChangeDetectionStrategy.Eager,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animations: decl.animations !== undefined ? new WrappedNodeExpr(decl.animations) : null,
defer,
changeDetection: decl.changeDetection ?? ChangeDetectionStrategy.Default,
changeDetection: decl.changeDetection ?? ChangeDetectionStrategy.OnPush,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeanMeche JeanMeche requested a review from alxhub March 24, 2026 00:02
The default change detection strategy is now OnPush.

BREAKING CHANGE: Component with undefined `changeDetection` property are now `OnPush` by default. Specify `changeDetection: ChangeDetectionStrategy.Eager` to keep the previous behavior.
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: fw-security

Copy link
Contributor

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: fw-security

@JeanMeche JeanMeche added the action: merge The PR is ready for merge by the caretaker label Mar 24, 2026
@JeanMeche JeanMeche removed the request for review from atscott March 24, 2026 22:45
@JeanMeche JeanMeche added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Mar 24, 2026
@JeanMeche
Copy link
Member Author

Caretaker note: Presubmit is a flake this is good to go

@leonsenft leonsenft merged commit eae8f7e into angular:main Mar 24, 2026
33 of 37 checks passed
@leonsenft
Copy link
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@JeanMeche JeanMeche deleted the onpush-default branch March 24, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants