Clear optionsFingerprint if element was destroyed

This commit is contained in:
Alex P 2023-09-11 10:50:39 +03:00
parent 50ca4dc079
commit dbe4e82707
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -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;