Skip to content

Commit ed5badd

Browse files
committed
Current better practice
1 parent ec588f5 commit ed5badd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

addon/components/stripe-element.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ export default Component.extend({
66
classNames: ['ember-stripe-element'],
77

88
autofocus: false,
9-
options: computed(() => ({})),
9+
options: null,
1010
stripeElement: null,
1111
stripeError: null,
1212
type: null, // Set in components that extend from `stripe-element`
1313

14+
init() {
15+
this._super(...arguments);
16+
set(this, 'options', {});
17+
},
18+
1419
stripev3: service(),
1520
elements: computed(function() {
1621
return get(this, 'stripev3.elements')();

tests/dummy/app/controllers/application.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Controller from '@ember/controller';
22
import { inject as service } from '@ember/service';
3-
import { computed, get, set } from '@ember/object';
3+
import { get, set } from '@ember/object';
44

55
let style = {
66
style: {
@@ -24,15 +24,14 @@ export default Controller.extend({
2424
stripev3: service(),
2525

2626
token: null,
27+
cardOptions: null,
28+
options: null,
2729

28-
cardOptions: computed(() => ({
29-
hidePostalCode: true,
30-
style
31-
})),
32-
33-
options: computed(() => ({
34-
style
35-
})),
30+
init() {
31+
this._super(...arguments);
32+
set(this, 'cardOptions', { hidePostalCode: true, style });
33+
set(this, 'options', { style });
34+
},
3635

3736
actions: {
3837
submit(stripeElement) {

0 commit comments

Comments
 (0)