@@ -13,19 +13,12 @@ export class HXDisclosureElement extends HXElement {
1313 return 'hx-disclosure' ;
1414 }
1515
16- static get observedAttributes ( ) {
17- return super . observedAttributes . concat ( [ 'aria-expanded' ] ) ;
18- }
19-
20- constructor ( ) {
21- super ( ) ;
16+ $onCreate ( ) {
2217 this . _onTargetOpen = this . _onTargetOpen . bind ( this ) ;
2318 this . _onTargetClose = this . _onTargetClose . bind ( this ) ;
2419 }
2520
26- connectedCallback ( ) {
27- super . connectedCallback ( ) ;
28-
21+ $onConnect ( ) {
2922 this . $upgradeProperty ( 'expanded' ) ;
3023 this . setAttribute ( 'role' , 'button' ) ;
3124 if ( ! this . hasAttribute ( 'tabindex' ) && ! this . disabled ) {
@@ -45,7 +38,7 @@ export class HXDisclosureElement extends HXElement {
4538 this . addEventListener ( 'keyup' , this . _keyUp ) ;
4639 }
4740
48- disconnectedCallback ( ) {
41+ $onDisconnect ( ) {
4942 this . removeEventListener ( 'click' , this . _toggle ) ;
5043 this . removeEventListener ( 'keydown' , this . $preventScroll ) ;
5144 this . removeEventListener ( 'keyup' , this . _keyUp ) ;
@@ -56,18 +49,18 @@ export class HXDisclosureElement extends HXElement {
5649 }
5750 }
5851
59- attributeChangedCallback ( attr , oldVal , newVal ) {
60- super . attributeChangedCallback ( attr , oldVal , newVal ) ;
52+ static get $observedAttributes ( ) {
53+ return [ 'aria-expanded' ] ;
54+ }
6155
62- switch ( attr ) {
63- case 'aria-expanded' :
64- if ( this . target ) {
65- let setTo = ( newVal === 'true' ) ;
66- if ( this . target . open !== setTo ) {
67- this . target . open = setTo ;
68- }
56+ $onAttributeChange ( attr , oldVal , newVal ) {
57+ if ( attr === 'aria-expanded' ) {
58+ if ( this . target ) {
59+ let setTo = ( newVal === 'true' ) ;
60+ if ( this . target . open !== setTo ) {
61+ this . target . open = setTo ;
6962 }
70- break ;
63+ }
7164 }
7265 }
7366
0 commit comments