Skip to content

Commit

Permalink
fix if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Jan 31, 2024
1 parent 0f49db5 commit 1d89af9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/helpers/attribute-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);
}
Expand Down

0 comments on commit 1d89af9

Please sign in to comment.