| @@ -839,8 +839,15 @@ | ||
| 839 | 839 | document.addEventListener('DOMContentLoaded', function () { |
| 840 | 840 | |
| 841 | 841 | const offCanvas = document.querySelector('." . esc_js($class_ID) . "'); |
| 842 | 842 | const overlay = document.querySelector('." . esc_js($overlay_ID) . "'); |
| 843 | + | |
| 844 | + // With no template picked the widget prints a placeholder instead of | |
| 845 | + // the panel markup, so these lookups come back empty. Bail out rather | |
| 846 | + // than throwing on insertBefore and losing the handlers below. | |
| 847 | + if (!offCanvas || !overlay) { | |
| 848 | + return; | |
| 849 | + } | |
| 843 | 850 | const video = offCanvas ? offCanvas.querySelector('.king-addons-video-popup-video') : null; |
| 844 | 851 | const autoplayEnabled = " . $hosted_autoplay_js . "; |
| 845 | 852 | const popupButton = document.querySelector('.king-addons-video-popup-button-" . esc_js((string) $this_ID) . "'); |
| 846 | 853 | |