Skip to content

Commit

Permalink
chore: use once
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Oct 16, 2024
1 parent edddd37 commit ce30076
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { fflags } from './fflags.js';
const { sampleRUM, queue, isSelected } = (window.hlx && window.hlx.rum) ? window.hlx.rum
/* c8 ignore next */ : {};

const formSubmitListener = (e) => sampleRUM('formsubmit', { target: targetSelector(e.target), source: sourceSelector(e.target) });

// eslint-disable-next-line no-use-before-define, max-len
const blocksMO = window.MutationObserver ? new MutationObserver(blocksMCB)
/* c8 ignore next */ : {};
Expand Down Expand Up @@ -236,8 +234,7 @@ function addFormTracking(parent) {
activateBlocksMO();
activateMediaMO();
parent.querySelectorAll('form').forEach((form) => {
form.removeEventListener('submit', formSubmitListener); // listen only once
form.addEventListener('submit', formSubmitListener);
form.addEventListener('submit', (e) => sampleRUM('formsubmit', { target: targetSelector(e.target), source: sourceSelector(e.target) }), { once: true });
});
}

Expand Down

0 comments on commit ce30076

Please sign in to comment.