fix(children directive): Capture target via closure to fix NgZone compatibility#7241
Open
Mich0608 wants to merge 3 commits intomicrosoft:mainfrom
Open
fix(children directive): Capture target via closure to fix NgZone compatibility#7241Mich0608 wants to merge 3 commits intomicrosoft:mainfrom
Mich0608 wants to merge 3 commits intomicrosoft:mainfrom
Conversation
added 3 commits
December 19, 2025 11:41
…standard observer.target property assignment
|
@Mich0608 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
📖 Description
This PR refactors the
ChildrenDirectiveto use proper closure-based state management instead of dynamically assigning properties toMutationObserverinstances, fixing compatibility issues with Angular and improving overall code quality.Problem with current implementation:
The current code assigns a custom
targetproperty directly toMutationObserverinstances:This approach has several issues:
targetis not a defined property onMutationObserver, so this relies on JavaScript's dynamic property assignmentMutationObserverto intercept callbacks for change detection, the observer instance passed to the callback is the patched version, not the native instance where thetargetproperty was assigned. This causesCannot read property 'target' of undefinederrors in Angular applications.Solution:
Refactor to use closure scope for state management. By creating the callback function inside
observe(), thetargetis naturally captured in the closure, eliminating the need to attach custom properties to the observer.🎫 Issues
👩💻 Reviewer Notes
📑 Test Plan
ChildrenDirectiveshould pass unchanged✅ Checklist
General
$ npm run change⏭ Next Steps