Comment

Comment by noduerme

There are really few times I find stopPropagation() necessary, and try to use it as little as possible. Usually it's something right there in a parent. Even so, the larger point here is that events are very hard to trace through code. This is why I always use enums or static variables to define the names (event types) of events any given class will emit within the class definition. It makes it a lot easier to see what other code references that static name than it does to find every instance of "click" in a huge codebase.

If you only add stopPropagation() when there's a reason, then at least later you know there had to be a reason.

parent noduerme 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton