From 1d89af9a17c5f633ab704b884968351f0da414f3 Mon Sep 17 00:00:00 2001 From: Stanislav Atroschenko Date: Wed, 31 Jan 2024 15:59:17 +0300 Subject: [PATCH] fix if condition --- src/helpers/attribute-utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/helpers/attribute-utils.ts b/src/helpers/attribute-utils.ts index 9e3bacc8c..1983a68ae 100644 --- a/src/helpers/attribute-utils.ts +++ b/src/helpers/attribute-utils.ts @@ -9,10 +9,11 @@ export const setAttributeToSelection = ( ) => { try { const nodes = document.querySelectorAll(selector); - if (nodes.length > 0) { - nodes.forEach((node) => node.setAttribute(attr, value)); - hit(source); + if (nodes.length === 0) { + return; } + nodes.forEach((node) => node.setAttribute(attr, value)); + hit(source); } catch { logMessage(source, `Failed to set attribute "${attr}" to "${value}" on "${selector}"`); }