@@ -65,15 +65,6 @@ const waitForElementChildren = createAwaitableMutationObserver({
65
65
isReady : ( el , selector ) => ! ! el ?. childElementCount && el ?. matches ?.( selector ) && el . childElementCount > 0 ,
66
66
} ) ;
67
67
68
- // const waitForElementAttribute = createAwaitableMutationObserver({
69
- // attributes: true,
70
- // // childList: true,
71
- // // subtree: true,
72
- // isReady: (el: HTMLElement | null, selector: string) => {
73
- // return el?.matches?.(selector) ?? false;
74
- // },
75
- // });
76
-
77
68
/**
78
69
* Detect when a Clerk component has mounted by watching DOM updates to an element with a `data-clerk-component="${component}"` property.
79
70
*/
@@ -90,21 +81,18 @@ export function useWaitForComponentMount(
90
81
}
91
82
92
83
if ( typeof window !== 'undefined' && ! watcherRef . current ) {
93
- const selector = `[data-clerk-component="${ component } "]` ;
94
- const attributeSelector = options ?. selector ;
95
- console . log ( 'attributeSelector' , attributeSelector , attributeSelector + selector ) ;
84
+ const defaultSelector = `[data-clerk-component="${ component } "]` ;
85
+ const selector = options ?. selector ;
96
86
watcherRef . current = waitForElementChildren ( {
97
- selector : attributeSelector ? attributeSelector + selector : selector ,
87
+ selector : selector
88
+ ? // Allows for `[data-clerk-component="xxxx"][data-some-attribute="123"] .my-class`
89
+ defaultSelector + selector
90
+ : defaultSelector ,
98
91
} )
99
- // .then(res => {
100
- // return attributeSelector ? waitForElementAttribute({ selector: attributeSelector + selector }) : res;
101
- // })
102
92
. then ( ( ) => {
103
- console . log ( 'rendered' , component ) ;
104
93
setStatus ( 'rendered' ) ;
105
94
} )
106
95
. catch ( ( ) => {
107
- console . log ( 'error' , component ) ;
108
96
setStatus ( 'error' ) ;
109
97
} ) ;
110
98
}
0 commit comments