Re: DOM-Events: Non-bubbleable means non-capturable?

* Sergey Ilinsky wrote:
>We've got several events that do not bubble, 
>they are: focus, blur, load etc.
>Due to them I have an unclear issue that I'd like to hear 
>your opinion on: Must ALL the events dispatched by the 
>implementation or by developer have capturing-phase 
>(including the ones mentioned above)?

http://www.w3.org/TR/DOM-Level-3-Events/ discusses this in section 1.1.1
and 1.2.1. The answer depends on the event flow model and the individual
event type. Specifically:

  This document specifies an event flow for tree-based structures: DOM
  event flow. While it is expected that HTML and XML applications will
  follow this event flow, applications might reuse the interfaces
  defined in this document for non tree-based structures. In that case,
  it is the responsibility of such applications to define their event
  flow and how it relates to the DOM event flow. An example of such use
  can be found in [DOM Level 3 Load and Save]. 

and later

  Some events may not necessarily accomplish the three phases of the DOM
  event flow, e.g. the event could only be defined for one or two
  phases. As an example, events defined in this specification will
  always accomplish the capture and target phases but some will not
  accomplish the bubbling phase ("bubbling events" versus "non-bubbling
  events", see also the Event.bubbles attribute).

The DOM Level 3 LSParser, as cited above, is an EventTarget with no
notion of parent or child, events will only accomplish the target phase.
Also note that it says all events defined in the document accomplish the
capture and target phases, so for the events you cite, the answer is yes
when used in the DOM event flow. Do you think the specification explains
that well enough?

>Since there is no DOM interface for dispatching 
>non-capturable events, I would guess the answer 
>to this question is "yes" but the test case given 
>below proves different behaviour in FF.

As noted in ISSUE-35, some implementations actually allow for this when
you call .stopPropagation() before dispatching the event. It is still an
open issue whether DOM Level 3 Events will require this, however.

><div id="test">
><input type="text"/>
></div>
><script type="text/javascript">
>document.getElementsById("test").addEventListener("focus", function(oEvent){alert(1);}, true);
></script>
>
>The alert is never fired, that actually means that 
>non-bubbleable event "focus" is non-capturable!
>This is appear to me to be wrong.

A better test would additionally check whether the event accomplishes
the target and bubble phases; the above, however, doesn't work because
you didn't check the JavaScript Console which would tell you that the
getElementsById method does not exist, it's getElementById (no 's').
Using that method, it works for me.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Friday, 24 March 2006 02:28:02 UTC