Skip to content

fix(core): skip DOM trigger registration in DeferBlockBehavior.Manual…#68866

Open
Rafaelkocharli wants to merge 1 commit into
angular:mainfrom
Rafaelkocharli:fix/defer-manual-mode-dom-trigger-registration
Open

fix(core): skip DOM trigger registration in DeferBlockBehavior.Manual…#68866
Rafaelkocharli wants to merge 1 commit into
angular:mainfrom
Rafaelkocharli:fix/defer-manual-mode-dom-trigger-registration

Conversation

@Rafaelkocharli
Copy link
Copy Markdown

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

When using DeferBlockBehavior.Manual in tests (e.g. Jest + JSDOM), Angular still
registers DOM observers for @defer trigger functions (on viewport, on hover,
on interaction). This causes ReferenceError: IntersectionObserver is not defined
and similar errors, because JSDOM does not implement these browser APIs.

Issue Number: #68800

What is the new behavior?

ɵɵdeferOnViewport, ɵɵdeferOnHover, and ɵɵdeferOnInteraction now call
shouldTriggerDeferBlock() before registering DOM triggers. In Manual mode
the check returns false, so no observers or event listeners are attached.
The existing SSR guard is replaced by this check, which already covers the
server-side case as well.

Does this PR introduce a breaking change?

  • No

Other information

shouldTriggerDeferBlock was made export so it can be reused in
instructions.ts alongside the existing shouldAttachTrigger.
ɵɵdeferOnIdle is unaffected — it delegates to scheduleDelayedTrigger
which already gates on shouldTriggerDeferBlock internally.

@pullapprove pullapprove Bot requested a review from kirjs May 21, 2026 18:16
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 21, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label May 21, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant