News for hackers. Stuff that matters.
Re:JavaScript useCapture demystified by jonchang on Monday March 04, 2013 @05:36AM (#5317603)
quirksmode has more historical background and actually explains what happens during capture and bubble and when you might want to use it.

http://www.quirksmode.org/js/events_order.html

Re:JavaScript useCapture demystified by kaio on Monday March 04, 2013 @06:05AM (#5317662)
Makes me wonder if there are any good reasons to support both [capturing, bubbling] ways of event propagation. I think the default W3C model does a pretty good job and is more consistent with the concept of the DOM _tree_ Mixing these two modes also seems to be a good source for hours of bughunting :~
Re:JavaScript useCapture demystified by dccoolgai on Monday March 04, 2013 @08:20AM (#5318015)
That was a really helpful read, thanks for sharing.
Re:JavaScript useCapture demystified by jdlshore on Monday March 04, 2013 @12:55PM (#5319407)
"When an event is attached to an element, it will fire once the event has fully bubbled up to the document."

This is not quite correct. The event will fire as it bubbles upward, not after it reaches the document level.

The DOM Events Level 3 specification has a helpful diagram:

http://www.w3.org/TR/DOM-Level-3-Events/#event-flow

There's also the "browser default" behavior, which is stuff like highlighting selected text. That does happen after the event finishes bubbling. (Usually.)

Note that stopping an event from bubbling (with `event.stopPropagation()`) and stopping an event's default behavior (with `event.preventDefault()`) are two separate, unrelated actions. However, returning false from an event handler is equivalent to doing both.

Re:JavaScript useCapture demystified by benhowdle89 on Monday March 04, 2013 @05:05AM (#5317542)
So far, feedback has been:

1. maybe an initial syntax overview: target.addEventListener(type, listener[, useCapture]);

2. I think it’d be worth explaining what capture and bubble are.

I agree!

Re:JavaScript useCapture demystified by csmattryder on Monday March 04, 2013 @05:26AM (#5317588)
Another helpful point would be when to use capture, and when to use bubble.

Did like this post though, I've only recently picked up JS and this confused me when I tried implementing listeners a few weeks ago for a project.