-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ivy): don't detect changes on detached child embedded views #34846
Conversation
c511e61
to
b3b55de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just left few comments / questions that I would like have your thoughts on.
|
||
TestBed.configureTestingModule({declarations: [App, ViewManipulation]}); | ||
const fixture = TestBed.createComponent(App); | ||
const vm: ViewManipulation = fixture.debugElement.childNodes[2].references['vm']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-nit / personal preference: in cases like this I usually do debugElement.query(By.directive(ViewManipulation)).injector.get(ViewManipulation)
as I find this approach less "brittle". (BTW, for quite a bit of time I wanted to have a better API to do just this in TestBed
but this is a separate story....).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: I tried it out and query
didn't manage to find the directive for some reason. Maybe because I'm trying to access it before the first change detection run?
Sure, I don't feel strongly about it. I did it this way, because the other unit tests were doing the same.
b3b55de
to
7613282
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed/replied to all of the feedback @pkozlowski-opensource.
|
||
TestBed.configureTestingModule({declarations: [App, ViewManipulation]}); | ||
const fixture = TestBed.createComponent(App); | ||
const vm: ViewManipulation = fixture.debugElement.childNodes[2].references['vm']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: I tried it out and query
didn't manage to find the directive for some reason. Maybe because I'm trying to access it before the first change detection run?
Sure, I don't feel strongly about it. I did it this way, because the other unit tests were doing the same.
7613282
to
6b9881f
Compare
I've added the extra unit test. |
Fixes Ivy detecting changes inside child embedded views, even though they're detached. Note that there's on subtlety here: I made the changes inside `refreshDynamicEmbeddedViews` rather than `refreshView`, because we support detecting changes on a detached view (evidenced by a couple of unit tests), but only if it's triggered directly from the view's `ChangeDetectorRef`, however we shouldn't be detecting changes in the detached child view when something happens in the parent. Fixes angular#34816.
6b9881f
to
feac972
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The size increase is unfortunate but I believe that it is mostly because of the creeping size increase from the previous PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm - global approval (the size diff is not caused by this change)
Fixes Ivy detecting changes inside child embedded views, even though they're detached. Note that there's on subtlety here: I made the changes inside `refreshDynamicEmbeddedViews` rather than `refreshView`, because we support detecting changes on a detached view (evidenced by a couple of unit tests), but only if it's triggered directly from the view's `ChangeDetectorRef`, however we shouldn't be detecting changes in the detached child view when something happens in the parent. Fixes #34816. PR Close #34846
…lar#34846) Fixes Ivy detecting changes inside child embedded views, even though they're detached. Note that there's on subtlety here: I made the changes inside `refreshDynamicEmbeddedViews` rather than `refreshView`, because we support detecting changes on a detached view (evidenced by a couple of unit tests), but only if it's triggered directly from the view's `ChangeDetectorRef`, however we shouldn't be detecting changes in the detached child view when something happens in the parent. Fixes angular#34816. PR Close angular#34846
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes Ivy detecting changes inside child embedded views, even though they're detached.
Note that there's one subtlety here: I made the changes inside
refreshDynamicEmbeddedViews
rather thanrefreshView
, because we support detecting changes on a detached view (evidenced by a couple of unit tests), but only if it's triggered directly from the view'sChangeDetectorRef
, however we shouldn't be detecting changes in the detached child view when something happens in the parent.Note: I had to bump the size limit, because it looks like master was right on the edge before these changes. I haven't introduced any new imports and the new logic is only a couple of lines so I doubt that these changes would've added too much to the size.
Fixes #34816.