onClick
instead of onclick
. I realize onclick
is correct, but it would be nice if it could also recognize onClick
value: boolean
to "true": string
. However, value
is not a boolean
and is actually a string
, which I found out when I removed the quotes from true
and that caused my button to stop working.I loaded up my workspace in VSCode and found that it accepted both onClick
and onclick
, and did not complain about hidden1.value !== "true"
. I love GoLand... how can I make it as smart of VSCode in these respects?
It appears that GoLand infers value
is a boolean
because of line 7 (setting value
with a boolean
). If I throw ToString()
on there, the warning goes away, but I'd like to not have to add this... it works fine as-is and a colleague using vscode likely won't add it, therefore I don't want it to cause an issue for me, using GoLand.
This is in an html file that contains javascript directly inside the <script>
tag. Is there a way to make this operate more like how vscode is seeing things?
My GoLand settings are HTML5, JSX syntax checking on, JS=ECMAScript 6+, TS=Bundled 4.7.4
function pgMpFunc(el1, el2) {
const hidden1 = document.getElementById(el1);
const hidden2 = document.getElementById(el2);
const turnOn = (hidden1.value !== "true");
setCheckbox(el1, turnOn);
hidden1.value = turnOn;
if (turnOn) {
setCheckbox(el2, !turnOn);
enableCheckbox(el2, !turnOn);
hidden2.value = !turnOn;
} else {
enableCheckbox(el2, true);
}
}
hidden1.value
is a Boolean, once you change itWe can see this because you are creating it from a Boolean expression:
const turnOn = (hidden1.value !== "true"); // Result is ALWAYS boolean
setCheckbox(el1, turnOn);
hidden1.value = turnOn; // And this is what you are putting in there
A better way to do that Boolean expression is as follows:
const turnOn = ! hidden1.value;
onclick
If your browser is permissive, it might accept onClick, but that is not the standard name and some browsers may not accept it.
Generally, many things in HTML are non-case-sensitive, but JS itself is case-sensitive.
Therefore while it might work to use random capitalization in the HTML, it is not a good idea, because one day you may forget and do that in the JS, and it will fail and be a difficult bug to resolve.