Skip to content

Commit

Permalink
tests: keeping size in check
Browse files Browse the repository at this point in the history
  • Loading branch information
vdua committed Dec 19, 2024
1 parent bca591c commit de34b69
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,33 +251,25 @@ function addViewMediaTracking(parent) {
}
}

function addFillTracking(parent) {
let lastSource;
parent.addEventListener('change', (event) => {
const source = sourceSelector(event.target);
if (source !== lastSource) {
sampleRUM('fill', { source });
lastSource = source;
}
});
}

function addFocusTracking(parent) {
parent.addEventListener('focusin', (event) => {
if (['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'].includes(event.target.tagName)
|| event.target.getAttribute('contenteditable') === 'true') {
sampleRUM('click', { source: sourceSelector(event.target) });
}
});
}

function addFormTracking(parent) {
activateBlocksMO();
activateMediaMO();
parent.querySelectorAll('form').forEach((form) => {
form.addEventListener('submit', (e) => sampleRUM('formsubmit', { target: targetSelector(e.target), source: sourceSelector(e.target) }), { once: true });
addFillTracking(form);
addFocusTracking(form);
let lastSource;
form.addEventListener('change', (e) => {
const source = sourceSelector(e.target);
if (source !== lastSource) {
sampleRUM('fill', { source });
lastSource = source;
}
});
form.addEventListener('focusin', (e) => {
if (['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'].includes(e.target.tagName)
|| e.target.getAttribute('contenteditable') === 'true') {
sampleRUM('click', { source: sourceSelector(e.target) });
}
});

Check warning on line 272 in modules/index.js

View check run for this annotation

Codecov / codecov/patch

modules/index.js#L259-L272

Added lines #L259 - L272 were not covered by tests
});
}

Expand Down

0 comments on commit de34b69

Please sign in to comment.