@pernod-ricard-global-cms/jsutils 3.2.1 → 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.
Files changed (2) hide show
  1. package/jsutils.mjs +6 -6
  2. package/package.json +1 -1
package/jsutils.mjs CHANGED
@@ -632,7 +632,10 @@ async function loadScript(src) {
632
632
  * @param {object} event The click event object
633
633
  */
634
634
  async function handleCTBClick(event) {
635
- if (!window.isCTBLoaded) {
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`);
@@ -640,12 +643,9 @@ async function handleCTBClick(event) {
640
643
 
641
644
  // This is important!! Never remove this code
642
645
  const clonedEvent = new event.constructor(event.type, event);
643
- const repeatEventInterval = setInterval(() => {
646
+ setTimeout(() => {
644
647
  event.target.dispatchEvent(clonedEvent);
645
- if (document.querySelector('.ctbuy-modal') !== null) {
646
- clearInterval(repeatEventInterval);
647
- }
648
- }, 100)
648
+ }, 500);
649
649
  }
650
650
  }
651
651
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pernod-ricard-global-cms/jsutils",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Handy collection of Javascript utility functions",
5
5
  "type": "commonjs",
6
6
  "main": "jsutils.mjs",