Re: DOMBuilder needs a getFeature

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;

> 
> Michael Mansell, 
> Senior Product Architect
> PureEdge Solutions
> Trusted Digital Relationships
> v: 250-708-8046  f: 250-708-8010
> 1-888-517-2675  http://www.PureEdge.com 
>  
> 

-- 
jst

Received on Monday, 19 May 2003 21:48:21 UTC