@pernod-ricard-global-cms/jsutils 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsutils.mjs +8 -4
- package/package.json +1 -1
package/jsutils.mjs
CHANGED
|
@@ -632,16 +632,20 @@ async function loadScript(src) {
|
|
|
632
632
|
* @param {object} event The click event object
|
|
633
633
|
*/
|
|
634
634
|
async function handleCTBClick(event) {
|
|
635
|
-
|
|
635
|
+
|
|
636
|
+
event.preventDefault();
|
|
637
|
+
|
|
638
|
+
if (!window.isCTBLoaded) {
|
|
636
639
|
const domain = window.location.hostname;
|
|
637
640
|
// Assuming PR-CLICKTOBUY plugin is enabled to make the script load
|
|
638
641
|
await loadScript(`/wp-content/plugins/pr-clicktobuy/public/js/pr-clicktobuy-public.js`);
|
|
639
642
|
window.isCTBLoaded = true;
|
|
640
643
|
|
|
641
644
|
// This is important!! Never remove this code
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
+
const clonedEvent = new event.constructor(event.type, event);
|
|
646
|
+
setTimeout(() => {
|
|
647
|
+
event.target.dispatchEvent(clonedEvent);
|
|
648
|
+
}, 500);
|
|
645
649
|
}
|
|
646
650
|
}
|
|
647
651
|
|