mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Clear optionsFingerprint if element was destroyed
This commit is contained in:
parent
50ca4dc079
commit
dbe4e82707
1 changed files with 8 additions and 0 deletions
|
@ -5,6 +5,7 @@ class MessageRenderer {
|
|||
constructor(config) {
|
||||
this.config = config;
|
||||
this.optionsFingerprint = null;
|
||||
this.currentNumber = 0;
|
||||
}
|
||||
|
||||
renderWithAmount(amount) {
|
||||
|
@ -18,12 +19,19 @@ class MessageRenderer {
|
|||
style: this.config.style
|
||||
};
|
||||
|
||||
// sometimes the element is destroyed while the options stay the same
|
||||
if (document.querySelector(this.config.wrapper).getAttribute('data-render-number') !== this.currentNumber.toString()) {
|
||||
this.optionsFingerprint = null;
|
||||
}
|
||||
|
||||
if (this.optionsEqual(options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newWrapper = document.createElement('div');
|
||||
newWrapper.setAttribute('id', this.config.wrapper.replace('#', ''));
|
||||
this.currentNumber++;
|
||||
newWrapper.setAttribute('data-render-number', this.currentNumber);
|
||||
|
||||
const oldWrapper = document.querySelector(this.config.wrapper);
|
||||
const sibling = oldWrapper.nextSibling;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue