Skip to content

Commit 5b218ff

Browse files
StevenElbergerjosemarluedke
authored andcommitted
Fix component destroy error
1 parent 2558f24 commit 5b218ff

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

addon/components/stripe-element.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,33 @@ export default Component.extend({
6868

6969
setEventListeners() {
7070
let stripeElement = get(this, 'stripeElement');
71-
stripeElement.on('ready', (event) => this.ready(stripeElement, event));
72-
stripeElement.on('blur', (event) => this.blur(stripeElement, event));
73-
stripeElement.on('focus', (event) => this.focus(stripeElement, event));
71+
72+
stripeElement.on('ready', (event) => {
73+
if (this.isDestroying || this.isDestroyed) {
74+
return;
75+
}
76+
this.sendAction('ready', stripeElement, event);
77+
});
78+
79+
stripeElement.on('blur', (event) => {
80+
if (this.isDestroying || this.isDestroyed) {
81+
return;
82+
}
83+
this.sendAction('blur', stripeElement, event)
84+
});
85+
86+
stripeElement.on('focus', (event) => {
87+
if (this.isDestroying || this.isDestroyed) {
88+
return;
89+
}
90+
this.sendAction('focus', stripeElement, event)
91+
});
92+
7493
stripeElement.on('change', (...args) => {
94+
if (this.isDestroying || this.isDestroyed) {
95+
return;
96+
}
97+
7598
let [{ complete, error: stripeError }] = args;
7699
this.change(stripeElement, ...args);
77100

0 commit comments

Comments
 (0)