🐛 Fix button insertion logic in block checkout

The Google Pay button was inserted into the wrong DOM wrapper
This commit is contained in:
Philipp Stracker 2024-08-07 23:07:04 +02:00
parent e9c557a361
commit 7f3636348b
No known key found for this signature in database
2 changed files with 9 additions and 9 deletions

View file

@ -659,8 +659,7 @@ export default class PaymentButton {
const wrapper = this.wrapperElement;
if ( this.#button ) {
this.log( 'addButton.removePrevious', this.#button );
wrapper.removeChild( this.#button );
this.removeButton();
}
this.#button = button;
@ -671,17 +670,18 @@ export default class PaymentButton {
* Removes the payment button from the DOM.
*/
removeButton() {
if ( ! this.isPresent ) {
if ( ! this.isPresent || ! this.#button ) {
return;
}
this.log( 'removeButton' );
if ( this.#button ) {
const wrapper = this.wrapperElement;
wrapper.removeChild( this.#button );
this.#button = null;
try {
this.wrapperElement.removeChild( this.#button );
} catch ( Exception ) {
// Ignore this.
}
this.#button = null;
}
}