mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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.spinner = spinner;
|
||||||
this.cardValid = false;
|
this.cardValid = false;
|
||||||
this.formValid = false;
|
this.formValid = false;
|
||||||
|
this.currentHostedFieldsInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render(wrapper, contextConfig) {
|
render(wrapper, contextConfig) {
|
||||||
|
@ -31,6 +32,12 @@ class CreditCardRenderer {
|
||||||
return;
|
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 gateWayBox = document.querySelector('.payment_box.payment_method_ppcp-credit-card-gateway');
|
||||||
const oldDisplayStyle = gateWayBox.style.display;
|
const oldDisplayStyle = gateWayBox.style.display;
|
||||||
gateWayBox.style.display = 'block';
|
gateWayBox.style.display = 'block';
|
||||||
|
@ -92,6 +99,7 @@ class CreditCardRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(hostedFields => {
|
}).then(hostedFields => {
|
||||||
|
this.currentHostedFieldsInstance = hostedFields;
|
||||||
const submitEvent = (event) => {
|
const submitEvent = (event) => {
|
||||||
this.spinner.block();
|
this.spinner.block();
|
||||||
if (event) {
|
if (event) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue