@@ -65,16 +65,12 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
6565 // TODO: Fail handling or cancellation needed?
6666 ( this as any ) . componentRef = { } ;
6767
68+ const contentChildrenTags = Array . from ( element . children ) . filter ( x => this . _componentFactory . ngContentSelectors . some ( sel => x . matches ( sel ) ) ) . map ( x => x . tagName . toLocaleLowerCase ( ) ) ;
6869 const toBeOrphanedChildren = Array . from ( element . children ) . filter ( x => ! this . _componentFactory . ngContentSelectors . some ( sel => x . matches ( sel ) ) ) ;
69- const contentChildren = Array . from ( element . children ) . filter ( x => this . _componentFactory . ngContentSelectors . some ( sel => x . matches ( sel ) ) ) ;
7070 for ( const iterator of toBeOrphanedChildren ) {
7171 // TODO: special registration OR config for custom
7272 }
7373
74- if ( contentChildren . length === 0 ) {
75- // no content children, emit event immediately, since there's nothing to be attached.
76- ( this as any ) . componentRef ?. instance ?. childrenAttached ?. emit ( ) ;
77- }
7874
7975 let parentInjector : Injector ;
8076 let parentAnchor : ViewContainerRef ;
@@ -157,6 +153,15 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
157153
158154 this . detectChanges ( ) ;
159155
156+ // check if there are any content children associated with a content query collection.
157+ // if no, then just emit the event, otherwise we wait for the collection to be updated in updateQuery.
158+ const contentChildrenTypes = this . config . filter ( x => contentChildrenTags . indexOf ( x . selector ) !== - 1 ) . map ( x => x . provideAs ?? x . component ) ;
159+ const contentQueryChildrenCollection = componentConfig . contentQueries . filter ( x => contentChildrenTypes . includes ( x . childType ) ) ;
160+ if ( contentQueryChildrenCollection . length === 0 ) {
161+ // no content children, emit event immediately, since there's nothing to be attached.
162+ ( this as any ) . componentRef ?. instance ?. childrenAttached ?. emit ( ) ;
163+ }
164+
160165 if ( parentAnchor && parentInjector ) {
161166 // attempt to attach the newly created ViewRef to the parents's instead of the App global
162167 const parentViewRef = parentInjector . get < ViewContainerRef > ( ViewContainerRef ) ;
0 commit comments