-
-
Notifications
You must be signed in to change notification settings - Fork 241
fix: Persist the original "parentNode" when "retrieving" the root View created by createEmbeddedView #1542
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
Conversation
…w created by createEmbeddedView
parentLayout.removeChild(rootLayout); | ||
rootLayout.parentNode = node; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Hi @NathanaelA ,
The reason for this fix is the following:
Setup:
- In components like RadListView/ListView the component itself is going to handle the adding of the created templates to the UI tree
- In those cases it is necessary to "remove" the view that is created by the Angular's createEmbeddedView because by design it automatically adds the created element to the UI tree
- This is done via the
getSingleViewRecursive
So here is the source of this leak:
- The created "queue" of parent > child relationship that is created inside
nativescript-angular
initially (before getSingleViewRecursive removes the view) sets the parentNode to the actual ContainerViewRef that is calling thecreateEmbeddedView
- Due to the above reason we have to remove that view from the UI tree which itself resets the parentNode to undefined because the elements (the template View) is removed from its parent
- Later on when the GC is triggered that View does not have its correct "parentNode" (the one that was set when the creation of
createEmbeddedView
was called) and it cannot be correctly removed from the "queue".
So this fix makes sure that even if we "remove a view" from the UI by using the getSingleViewRecursive
its "representation" in the internal elements queue will be correct and will be GC collectable.
The fix does look a bit mystical, but I think it is correct. As @VladimirAmiorkov explained - we do this trick of creating an element with angular API ( With this fix we preserve this relation trough @sis0k0 Can you also take a look? Do you think this fix might have "side-effects"? |
This comment was marked as abuse.
This comment was marked as abuse.
Hey @NathanaelA, here is the plan:
This fix should be in all of the above releases |
This comment was marked as abuse.
This comment was marked as abuse.
test build_ng_routable_animations build_ng_animation_examples |
PR Checklist
What is the current behavior?
When using the Angular
createEmbeddeedView
from theViewContainerRef
, after callingclear()
the created NativeScript Views are left in the memoryWhat is the new behavior?
When using the Angular
createEmbeddeedView
from theViewContainerRef
, after callingclear()
the created NativeScript Views are left in the memoryFixes/Implements/Closes #[Issue Number].
ProgressNS/nativescript-ui-feedback#825