Skip to content

Commit

Permalink
log on invalid delay
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Oct 6, 2022
1 parent 37442d2 commit 26dab5c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scriptlets/trusted-click-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ import {
*/
/* eslint-enable max-len */
export function trustedClickElement(source, selectors, delay, extraMatch = '') {
// eslint-disable-next-line no-console
const log = console.log.bind(console);

const OBSERVER_TIMEOUT = 10000;
const SELECTORS_DELIMITER = ',';
const EXTRA_MATCH_DELIMITER = ',';
Expand All @@ -63,7 +66,8 @@ export function trustedClickElement(source, selectors, delay, extraMatch = '') {
let parsedDelay;
if (delay) {
parsedDelay = parseInt(delay, 10);
if (Number.isNaN(parsedDelay)) {
if (Number.isNaN(parsedDelay) || parsedDelay > OBSERVER_TIMEOUT) {
log(`Passed delay '${delay}' is invalid or bigger than ${OBSERVER_TIMEOUT}ms`);
return;
}
}
Expand Down

0 comments on commit 26dab5c

Please sign in to comment.