@@ -122,16 +122,13 @@ class PfeCollapseToggle extends PFElement {
122122 if ( this . controlledPanel ) {
123123 this . controlledPanel . expanded = this . expanded ;
124124
125- this . dispatchEvent (
126- new CustomEvent ( `${ PfeCollapse . tag } :change` , {
127- detail : {
128- expanded : this . expanded ,
129- toggle : this ,
130- panel : this . controlledPanel
131- } ,
132- bubbles : true
133- } )
134- ) ;
125+ this . emitEvent ( PfeCollapse . events . change , {
126+ detail : {
127+ expanded : this . expanded ,
128+ toggle : this ,
129+ panel : this . controlledPanel
130+ }
131+ } ) ;
135132 } else {
136133 console . warn (
137134 `${ this . tag } : This toggle doesn't have a panel associated with it`
@@ -171,6 +168,13 @@ class PfeCollapsePanel extends PFElement {
171168 return "pfe-collapse-panel" ;
172169 }
173170
171+ static get events ( ) {
172+ return {
173+ animationStart : `${ this . tag } :animation-start` ,
174+ animationEnd : `${ this . tag } :animation-end`
175+ } ;
176+ }
177+
174178 get templateUrl ( ) {
175179 return "pfe-collapse-panel.html" ;
176180 }
@@ -269,27 +273,21 @@ class PfeCollapsePanel extends PFElement {
269273 this . _transitionEndHandler
270274 ) ;
271275
272- this . dispatchEvent (
273- new CustomEvent ( `${ PfeCollapsePanel . tag } :animation-end` , {
274- detail : {
275- expanded : this . expanded ,
276- panel : this
277- } ,
278- bubbles : true
279- } )
280- ) ;
276+ this . emitEvent ( PfeCollapsePanel . events . animationEnd , {
277+ detail : {
278+ expanded : this . expanded ,
279+ panel : this
280+ }
281+ } ) ;
281282 }
282283
283284 _fireAnimationEvent ( state ) {
284- this . dispatchEvent (
285- new CustomEvent ( `${ PfeCollapsePanel . tag } :animation-start` , {
286- detail : {
287- state : state ,
288- panel : this
289- } ,
290- bubbles : true
291- } )
292- ) ;
285+ this . emitEvent ( PfeCollapsePanel . events . animationStart , {
286+ detail : {
287+ state : state ,
288+ panel : this
289+ }
290+ } ) ;
293291 }
294292}
295293
@@ -318,6 +316,12 @@ class PfeCollapse extends PFElement {
318316 return [ "pfe-animation" ] ;
319317 }
320318
319+ static get events ( ) {
320+ return {
321+ change : `${ this . tag } :change`
322+ } ;
323+ }
324+
321325 constructor ( pfeClass ) {
322326 super ( pfeClass || PfeCollapse ) ;
323327
@@ -327,9 +331,15 @@ class PfeCollapse extends PFElement {
327331 this . _changeHandler = this . _changeHandler . bind ( this ) ;
328332 this . _observer = new MutationObserver ( this . _linkControls ) ;
329333
330- this . addEventListener ( `${ PfeCollapse . tag } :change` , this . _changeHandler ) ;
331- this . addEventListener ( `${ PfeCollapsePanel . tag } :animation-start` , this . _animationStartHandler ) ;
332- this . addEventListener ( `${ PfeCollapsePanel . tag } :animation-end` , this . _animationEndHandler ) ;
334+ this . addEventListener ( PfeCollapse . events . change , this . _changeHandler ) ;
335+ this . addEventListener (
336+ PfeCollapse . events . animationStart ,
337+ this . _animationStartHandler
338+ ) ;
339+ this . addEventListener (
340+ PfeCollapse . events . animationEnd ,
341+ this . _animationEndHandler
342+ ) ;
333343 }
334344
335345 connectedCallback ( ) {
@@ -348,9 +358,15 @@ class PfeCollapse extends PFElement {
348358 }
349359
350360 disconnectedCallback ( ) {
351- this . removeEventListener ( `${ PfeCollapse . tag } :change` , this . _changeHandler ) ;
352- this . removeEventListener ( `${ PfeCollapsePanel . tag } :animation-start` , this . _animationStartHandler ) ;
353- this . removeEventListener ( `${ PfeCollapsePanel . tag } :animation-end` , this . _animationEndHandler ) ;
361+ this . removeEventListener ( PfeCollapse . events . change , this . _changeHandler ) ;
362+ this . removeEventListener (
363+ PfeCollapse . events . animationStart ,
364+ this . _animationStartHandler
365+ ) ;
366+ this . removeEventListener (
367+ PfeCollapse . events . animationEnd ,
368+ this . _animationEndHandler
369+ ) ;
354370 this . _observer . disconnect ( ) ;
355371 }
356372
@@ -389,9 +405,7 @@ class PfeCollapse extends PFElement {
389405 this . classList . remove ( "animating" ) ;
390406 }
391407
392- _changeHandler ( event ) {
393-
394- }
408+ _changeHandler ( event ) { }
395409}
396410
397411PFElement . create ( PfeCollapse ) ;
0 commit comments