Skip to content

Commit 2d10a05

Browse files
committed
refactor(elements): internal parent element cache
1 parent fe2a55f commit 2d10a05

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

projects/igniteui-angular-elements/src/app/custom-strategy.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
2424
// public override componentRef: ComponentRef<any>|null = null;
2525

2626
protected element: IgcNgElement;
27+
/** The parent _component_'s element (a.k.a the semantic parent, rather than the DOM one after projection) */
28+
protected parentElement?: WeakRef<IgcNgElement>;
2729
/** Native Angular parent (if any) the Element is created under, usually as template of dynamic component (e.g. HGrid row island paginator) */
2830
protected angularParent: ComponentRef<any>;
2931
/** Cached child instances per query prop. Used for dynamic components's child templates that normally persist in Angular runtime */
@@ -76,10 +78,10 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
7678
// TODO: Fail handling or cancellation needed?
7779
(this as any).componentRef = {};
7880

79-
const toBeOrphanedChildren = Array.from(element.children).filter(x => !this._componentFactory.ngContentSelectors.some(sel => x.matches(sel)));
80-
for (const iterator of toBeOrphanedChildren) {
81-
// TODO: special registration OR config for custom
82-
}
81+
// const toBeOrphanedChildren = Array.from(element.children).filter(x => !this._componentFactory.ngContentSelectors.some(sel => x.matches(sel)));
82+
// for (const iterator of toBeOrphanedChildren) {
83+
// // TODO: special registration OR config for custom
84+
// }
8385
let parentInjector: Injector;
8486
let parentAnchor: ViewContainerRef;
8587
const parents: IgcNgElement[] = [];
@@ -113,6 +115,7 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
113115
// ngElementStrategy getter is protected and also has initialization logic, though that should be safe at this point
114116
if (parent?.ngElementStrategy) {
115117
this.angularParent = parent.ngElementStrategy.angularParent;
118+
this.parentElement = new WeakRef(parent);
116119
let parentComponentRef = await parent?.ngElementStrategy[ComponentRefKey];
117120
parentInjector = parentComponentRef?.injector;
118121

0 commit comments

Comments
 (0)