Don't try to select a card if there is no selectTarget

This error was being thrown when the user had no cards saved:
```
Error: Missing target element "stripe-cards.select"
```
This commit is contained in:
Matt-Yorkley
2021-12-20 15:41:22 +00:00
parent f18fc3c2f3
commit a64f654697

View File

@@ -6,7 +6,9 @@ export default class extends Controller {
static targets = ["stripeelements", "select"];
connect() {
this.selectCard(this.selectTarget.value);
if (this.hasSelectTarget) {
this.selectCard(this.selectTarget.value);
}
}
onSelectCard(event) {