🦺 Add check for config that causes infinite loop

This commit is contained in:
Philipp Stracker 2024-06-07 21:12:34 +02:00
parent 33c6c06e85
commit 93f3e4e7ac
No known key found for this signature in database
2 changed files with 8 additions and 0 deletions

View file

@ -139,6 +139,10 @@ class GooglepayButton {
initEventHandlers() {
const { wrapper, ppcpButtonWrapper } = this.contextConfig();
if (wrapper === ppcpButtonWrapper) {
throw new Error(`[GooglePayButton] "wrapper" and "ppcpButtonWrapper" values must differ to avoid infinite loop. Current value: "${wrapper}"`);
}
const syncButtonVisibility = () => {
const $ppcpButtonWrapper = jQuery(ppcpButtonWrapper);
setVisible(wrapper, $ppcpButtonWrapper.is(':visible'));