Skip to content

Commit 3dce8b5

Browse files
author
Cathy Siller
committed
refactor(hx-accordion): compatibility audit update
1 parent 405dceb commit 3dce8b5

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

src/helix-ui/elements/HXAccordionElement.js

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { 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

Comments
 (0)