Skip to content

Commit

Permalink
Include Stripe Element and event in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvanderbyl committed Aug 22, 2017
1 parent 330ebc6 commit 468c25b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions addon/components/stripe-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const {
Component,
get,
inject: { service },
set,
run
set
} = Ember;

export default Component.extend({
Expand All @@ -21,10 +20,7 @@ export default Component.extend({

didInsertElement() {
this._super(...arguments);
run.schedule('afterRender', this, this._createStripeElement);
},

_createStripeElement() {
let elements = get(this, 'stripev3.elements')();

// Fetch user options
Expand Down Expand Up @@ -70,12 +66,12 @@ export default Component.extend({

setEventListeners() {
let stripeElement = get(this, 'stripeElement');
stripeElement.on('blur', () => this.sendAction('blur'));
stripeElement.on('focus', () => this.sendAction('focus'));
stripeElement.on('blur', (event) => this.sendAction('blur', stripeElement, event));
stripeElement.on('focus', (event) => this.sendAction('focus', stripeElement, event));
stripeElement.on('change', (...args) => {
let { error } = args[0];
set(this, 'error', error);
this.sendAction('change', ...args);
this.sendAction('change', stripeElement, ...args);
});
}
});

0 comments on commit 468c25b

Please sign in to comment.