Skip to content

Commit

Permalink
avoid negative variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaleleka committed Feb 7, 2024
1 parent 78b3340 commit 6d12f81
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/scriptlets/set-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ export function setAttr(source, selector, attr, value = '') {
const allowedValues = ['true', 'false'];

const shouldCopyValue = value.startsWith('[') && value.endsWith(']');
const isIllegalValue = value.length !== 0
&& (nativeIsNaN(parseInt(value, 10))
|| parseInt(value, 10) < 0
|| parseInt(value, 10) > 32767)
&& !allowedValues.includes(value.toLowerCase());

if (!shouldCopyValue && isIllegalValue) {
const isValidValue = value.length === 0
|| (!nativeIsNaN(parseInt(value, 10))
&& parseInt(value, 10) > 0
&& parseInt(value, 10) < 32767)
|| allowedValues.includes(value.toLowerCase());

if (!shouldCopyValue && !isValidValue) {
logMessage(source, 'Illegal attribute value provided');
return;
}
Expand Down

0 comments on commit 6d12f81

Please sign in to comment.