Fix js error check if element exist before using it

This commit is contained in:
Emili Castells Guasch 2024-11-04 12:57:00 +01:00
parent d4e0167d88
commit d219157bcd

View file

@ -407,10 +407,17 @@ class ApplePayButton {
.querySelectorAll( 'style#ppcp-hide-apple-pay' )
.forEach( ( el ) => el.remove() );
const paymentMethodAppleLi = document.querySelector('.wc_payment_method.payment_method_ppcp-applepay' );
if (paymentMethodAppleLi.style.display === 'none' || paymentMethodAppleLi.style.display === '') {
paymentMethodAppleLi.style.display = 'block';
}
const paymentMethodAppleLi = document.querySelector(
'.wc_payment_method.payment_method_ppcp-applepay'
);
if (
paymentMethodAppleLi &&
( paymentMethodAppleLi.style.display === 'none' ||
paymentMethodAppleLi.style.display === '' )
) {
paymentMethodAppleLi.style.display = 'block';
}
this.allElements.forEach( ( element ) => {
element.style.display = '';