mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Teardown hosted fields on re-render
This commit is contained in:
parent
93f0667075
commit
10d7574e22
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,7 @@ class CreditCardRenderer {
|
|||
this.spinner = spinner;
|
||||
this.cardValid = false;
|
||||
this.formValid = false;
|
||||
this.currentHostedFieldsInstance = null;
|
||||
}
|
||||
|
||||
render(wrapper, contextConfig) {
|
||||
|
@ -31,6 +32,12 @@ class CreditCardRenderer {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.currentHostedFieldsInstance) {
|
||||
this.currentHostedFieldsInstance.teardown()
|
||||
.catch(err => console.error(`Hosted fields teardown error: ${err}`));
|
||||
this.currentHostedFieldsInstance = null;
|
||||
}
|
||||
|
||||
const gateWayBox = document.querySelector('.payment_box.payment_method_ppcp-credit-card-gateway');
|
||||
const oldDisplayStyle = gateWayBox.style.display;
|
||||
gateWayBox.style.display = 'block';
|
||||
|
@ -92,6 +99,7 @@ class CreditCardRenderer {
|
|||
}
|
||||
}
|
||||
}).then(hostedFields => {
|
||||
this.currentHostedFieldsInstance = hostedFields;
|
||||
const submitEvent = (event) => {
|
||||
this.spinner.block();
|
||||
if (event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue