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

This error was being thrown when the user had no cards saved:
```
TypeError: stripeCardsController is null
```
This commit is contained in:
Matt-Yorkley
2021-12-20 17:25:04 +00:00
parent a64f654697
commit 9525e353a3

View File

@@ -12,14 +12,15 @@ export default class extends Controller {
selectPaymentMethod(event) {
this.doSelectPaymentMethod(event.target.dataset.paymentmethodId);
const stripeCardsController =
const stripeCardSelector =
this.application.getControllerForElementAndIdentifier(
document
.getElementById(event.target.dataset.paymentmethodId)
.querySelector('[data-controller="stripe-cards"]'),
"stripe-cards"
);
stripeCardsController.connect();
stripeCardSelector?.connect();
}
doSelectPaymentMethod(paymentMethodContainerId) {