I just came across a question that has been deleted now because apparently I left a snarky comment.
The question provided a code snippet in JavaScript with the following syntax (the code is not exactly as in the question since I can no longer view it).
let myDiv = document.getElementById("some-div");
myDiv.addEventListener("click", function() {
alert("some div"), true;
});
The OP mentioned setting the capture
flag to true
which I noticed wasn't correct because I saw a syntax error in the script.
Now I don't know if that syntax error is the cause of the OP's issues so instead of leaving a detailed answer, I simply left a comment in hopes that the OP can correct the syntax and maybe even fix the problem. All I said was:
You didn't set
{capture: true}
. Your syntax is incorrect.
Another user commented after that saying that a Boolean third parameter to addEventListener
is equivalent to setting the capture
flag.
Now this other user has waaaaaaaay more points than I do and I am not a JavaScript expert so I thought maybe you can set it that way and maybe this other user is correct, but I responded anyway trying to have a nice discussion.
I then commented back saying:
That doesn't look like a third parameter to
addEventListener
to me.
To which this other user acknowledges the error in the syntax. Okay good, I'm not going crazy. But at the same time this other user acknowledged the syntax error, he also said that I shouldn't just say "You have a syntax error" but instead to provide more details.
I was about to write a response to say that I only wanted to point out a syntax error but not really provide an answer because I didn't really know if the syntax error is the cause of the issue. I just wanted the OP to look into it. When I said "You didn't set {capture: true}
" I identified an issue, and by saying "Your syntax is incorrect" I hinted at where the OP might possibly look at to fix it. But before I could finish writing my response, the OP responded saying something like the reason why people don't like asking questions is because people like me leave snarky comments. And the OP then proceeded to delete the question.
In retrospect, maybe the "That doesn't look like a third parameter to addEventListener
to me" could've been phrased better but I don't know. I thought I tried to help but I guess I did it wrong?
function f(){1,3}
is perfectly ok), also it is possible you mis-remember the exact code... Providing more specific comments is generally safer and more actionable. (Also note that most people posting such questions don't know what "syntax" or "syntax error" is, so "you have syntax error" is at least useless for them)