11import { HXElement } from './HXElement' ;
22
3- import { replaceWith } from '../utils' ;
3+ import { defer } from '../utils' ;
44
55/**
66 * Fires in single-panel mode, when the current panel changes.
@@ -24,17 +24,19 @@ export class HXAccordionElement extends HXElement {
2424 }
2525
2626 $onCreate ( ) {
27+ this . $onConnect = defer ( this . $onConnect ) ;
2728 this . _onPanelOpen = this . _onPanelOpen . bind ( this ) ;
2829 }
2930
30- // FIXME: defer $onConnect until children finished connecting
3131 $onConnect ( ) {
3232 this . $upgradeProperty ( 'currentPanel' ) ;
3333 this . panels . forEach ( panel => {
3434 panel . addEventListener ( 'open' , this . _onPanelOpen ) ;
3535 } ) ;
3636
37- // FIXME: if current-panel set, ensure the associated panel is open
37+ if ( this . _isNavigable ) {
38+ this . _openPanel ( this . currentPanel ) ;
39+ }
3840 }
3941
4042 $onDisconnect ( ) {
@@ -67,7 +69,10 @@ export class HXAccordionElement extends HXElement {
6769 * not just the immediate children.
6870 */
6971 get panels ( ) {
70- // (VERIFY) FIXME: return [] if not connected
72+ if ( ! this . isConnected ) {
73+ return [ ] ;
74+ }
75+
7176 return Array . from ( this . querySelectorAll ( 'hx-accordion-panel' ) ) ;
7277 }
7378
@@ -123,7 +128,6 @@ export class HXAccordionElement extends HXElement {
123128
124129 /** @private */
125130 _onPanelOpen ( evt ) {
126- // FIXME: idx could be -1 if _onPanelOpen() called before connect
127131 let idx = this . panels . indexOf ( evt . target ) ;
128132 if ( this . _isNavigable ) {
129133 this . currentPanel = idx ;
@@ -144,22 +148,4 @@ export class HXAccordionElement extends HXElement {
144148 } ) ;
145149 }
146150 }
147-
148- // FIXME: remove for v0.15
149- /**
150- * @deprecated Use {@link HXAccordionElement#selectNext|selectNext()}
151- */
152- nextPanel ( ) {
153- replaceWith ( 'HXAccordionElement#selectNext()' ) ;
154- this . selectNext ( ) ;
155- }
156-
157- // FIXME: remove for v0.15
158- /**
159- * @deprecated Use {@link HXAccordionElement#selectPrevious|selectPrevious()}
160- */
161- previousPanel ( ) {
162- replaceWith ( 'HXAccordionElement#selectPrevious()' ) ;
163- this . selectPrevious ( ) ;
164- }
165151}
0 commit comments