Skip to content

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

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

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

Conversation

@JeanMeche

Copy link
Copy Markdown
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 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

@JeanMeche JeanMeche Mar 23, 2026

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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.

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

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

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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