File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
packages/components/bolt-accordion/src Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -204,19 +204,21 @@ class BoltAccordion extends withContext(withLitHtml()) {
204
204
// Array passed to the Accordion plugin, a series of trigger/content pairs
205
205
this . accordionItems = [ ] ;
206
206
207
- this . accordionItemElements . forEach ( item => {
208
- const onItemReady = e => {
209
- if ( e . detail . name !== 'bolt-accordion-item' ) return ;
210
- this . handleAccordionItemReady ( item ) ;
211
- item . removeEventListener ( 'rendered' , onItemReady ) ;
212
- } ;
213
-
214
- if ( item . _wasInitiallyRendered || this . _wasMutated ) {
207
+ Promise . all (
208
+ this . accordionItemElements . map ( item => {
209
+ if ( item . _wasInitiallyRendered || this . _wasMutated ) return ;
210
+ return new Promise ( ( resolve , reject ) => {
211
+ item . addEventListener ( 'ready' , e => {
212
+ return item === e . target && resolve ( ) ;
213
+ } ) ;
214
+ item . addEventListener ( 'error' , reject ) ;
215
+ } ) ;
216
+ } ) ,
217
+ ) . then ( ( ) => {
218
+ this . accordionItemElements . forEach ( item => {
215
219
this . handleAccordionItemReady ( item ) ;
216
- this . _wasMutated = false ;
217
- } else {
218
- item . addEventListener ( 'rendered' , onItemReady ) ;
219
- }
220
+ } ) ;
221
+ this . _wasMutated = false ;
220
222
} ) ;
221
223
}
222
224
You can’t perform that action at this time.
0 commit comments