- From: Mike Mansell <MMansell@PureEdge.com>
- Date: Mon, 19 May 2003 23:58:39 -0700
- To: "Johnny Stenback" <jst@netscape.com>
- Cc: <www-dom@w3.org>
Johnny Stenback wrote:
> Mike Mansell wrote:
> > As of the spec:
> >
> > http://www.w3.org/TR/2003/WD-DOM-Level-3-LS-20030226/load-save.html
> >
> > The DOMBuilder section has this description:
> >
> > ---
> > Asynchronous DOMBuilder objects are expected to also implement the
> > events::EventTarget interface so that event listeners can be registered
> > on asynchronous DOMBuilder objects.
> > ---
> >
> > However, in order to implement the EventTarget interface, the DOMBuilder
> > (which does NOT inherit from Node), needs the getFeature method. This
> > will allow someone to go:
> >
> > DOMBuilder myBuilder;
> > EventTarget myTarget;
> >
> > myTarget = (EventTarget)myBuilder.getFeature("Events", "3.0");
> > myTarget.addEventListenerNS("http://www.w3.org/2002/DOMLS",
> > "load", myListener, true, NULL);
>
> Just like all DOM specs prior to the Level 3 specs, it's fine to rely on
> binding specific casting to obtain the the interfaces that an object is
> stated to implement. And especially in this case, where the DOMBuilder
> itself will be the event target, it *must* be the same object (or an
> object that's castable from A->B->A) since once the event handler is
> called, the event's target will be the DOMBuilder, at which point you'll
> need to cast the EventTarget to a DOMBuilder (unless you want
> EventTarget to also have a getFeature() method?). IMO there's no need
> for this. The below code should do the right thing in all compliant
> implementations:
>
> DOMBuilder myBuilder;
> EventTarget myTarget;
>
> myTarget = (EventTarget)myBuilder;
> myTarget.addEventListenerNS("http://www.w3.org/2002/DOMLS",
> "load", myListener, true, NULL);
>
> and then in myListener::HandleEvent():
>
> DOMBuilder myBuilder = (DOMBuilder)event.target;
>
While I agree with you in practice, my feeling is that whole point behind
the getFeature() method was to allow for implementions to have the flexibility
in delegating DOM functionality to third-party code (See section
1.1.12. Mixed DOM implementations in the core spec). I feel that the
specifications from the W3C should "eat-their-own-dog-food" so to speak.
Therefore, we should not assume that the object implementing DOMBuilder
must implement EventTarget. Therefore, you need a getFeature on DOMBuilder.
If you feel that DOMBuilder *MUST* implement EventTarget, then change the
definition of DOMBuilder to actually extend EventTarget.
And yes, I do think that EventTarget should have a getFeature() method.
I'll be sending a separate email on that topic later.
Cheers,
Mike M
Received on Tuesday, 20 May 2003 02:58:46 UTC