As stated on the W3 website, click events are considered to be bubbling events.
Essentially, what does this mean? A clear explanation can be found here:
Bubbling: This refers to the process in which an event moves upwards through its ancestors after being processed at the target of the event.
The issue arises when dealing with scrollbars, as we need to determine whether they should:
- halt the propagation of a click event,
- allow it to bubble up to a more suitable handler (such as the div element), or
- respond to the event while also allowing it to bubble up for ancestors to capture it.
Further elaborating on the matter, the same W3 resource explains the nature of a scroll event:
Scroll: This event is triggered when a document view is scrolled.
A scrollbar is typically expected to manage the scrolling of a document view (like a div) without disrupting its intended behavior, including event propagation.
The initial hurdle arose back when mouse scroll wheels were merely a concept, and clicking was necessary to initiate scrolling! Consequently, both behaviors 1 and 3 hold merit in this scenario (one prioritizing the scrollbar, while the other considering both the scrollbar and ancestors).
In essence, there isn't a defined standard for this particular situation yet. Browser developers have the liberty to opt for either approach, both of which are deemed valid.
To ensure consistent behavior across various browsers, one potential solution could involve capturing scrollbar clicks (applicable to Firefox and Chrome) and triggering the div's click event accordingly.