@@ -70,24 +70,15 @@ export default Component.extend({
7070 let stripeElement = get ( this , 'stripeElement' ) ;
7171
7272 stripeElement . on ( 'ready' , ( event ) => {
73- if ( this . isDestroying || this . isDestroyed ) {
74- return ;
75- }
76- this . sendAction ( 'ready' , stripeElement , event ) ;
73+ this . _invokeAction ( 'ready' , stripeElement , event )
7774 } ) ;
7875
7976 stripeElement . on ( 'blur' , ( event ) => {
80- if ( this . isDestroying || this . isDestroyed ) {
81- return ;
82- }
83- this . sendAction ( 'blur' , stripeElement , event )
77+ this . _invokeAction ( 'blur' , stripeElement , event )
8478 } ) ;
8579
8680 stripeElement . on ( 'focus' , ( event ) => {
87- if ( this . isDestroying || this . isDestroyed ) {
88- return ;
89- }
90- this . sendAction ( 'focus' , stripeElement , event )
81+ this . _invokeAction ( 'focus' , stripeElement , event )
9182 } ) ;
9283
9384 stripeElement . on ( 'change' , ( ...args ) => {
@@ -99,15 +90,25 @@ export default Component.extend({
9990 this . change ( stripeElement , ...args ) ;
10091
10192 if ( complete ) {
102- this . complete ( stripeElement ) ;
93+ this . _invokeAction ( 'complete' , stripeElement )
10394 } else if ( stripeError ) {
104- this . error ( stripeError ) ;
95+ this . _invokeAction ( 'error' , stripeError )
10596 }
10697
10798 set ( this , 'stripeError' , stripeError ) ;
10899 } ) ;
109100 } ,
110101
102+ _invokeAction ( method , ...args ) {
103+ if ( this . isDestroying || this . isDestroyed ) {
104+ return ;
105+ }
106+
107+ if ( typeof this [ method ] === 'function' ) {
108+ this [ method ] ( ...args )
109+ }
110+ } ,
111+
111112 ready ( ) { } ,
112113 blur ( ) { } ,
113114 focus ( ) { } ,
0 commit comments