W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

Re: Subclassing DOM nodes

From: John Ky <hand@syd.speednet.com.au>
Date: Thu, 12 Oct 2000 05:44:53 +1000
Message-ID: <00d301c033bb$ba0ed8d0$0400a8c0@NEWHOGGY>
To: <www-dom@w3.org>
> Another possible approach,less elegant but more portable, would be a
> "lightweight subclassing" scheme. Here, you would annotate "standard"
nodes
> rather than subclassing them -- eg, by providing one or more tables
indexed
> by node identity which can be used to retrieve whatever additional
> information and/or code you want to associate with it.
>
> The challenge here is that "node identity" is not necessarily the same as
> the address of the Node object (eg if your DOM is a proxy for some other
> data structure, you might have several objects proxying the same datum and
> thus representing "the same node), so it isn't clear what could be used as
> an index for those tables. DOM Level 3 is investigating this.

I may be wrong, but it is my impression that Mutation Events are another
extensibility mechanism.

Instead of having a class heirarchy for Elements, it might be possible to
have a heirarchy of ElementListeners instead.  When an Element has
an ElementListener registered on it, it will be augmented with the
ElementListener's behavour.  With this approach, communicating with
the added behaviour would be through the dispatch of events rather
than through function calls - so you lose the function call semantics in
favour of a very flexible extensibility mechanism.

For instance, instead of calling Draw method, you can dispatch a
Draw Event to the element.

I think this could possibly be another use case of an At-Target only
dispatch.  There is potential in a class of events that are only
dispatched to single nodes.

To further the extensibility, it may also be possible to introduce
Creation Events.  Creation Event Listeners could be
registered on the document node to watch for the creation of
new nodes.  When a node is created, the Creation Event Listener
would have the opportunity to initialise new nodes with behaviour
by adding Element Listeners to Elements for example.

I have been told before that Mutation Events represent an
extensibility framework.  I take it that this is a representation
of what they meant - but I can't be sure.

Thanks

-John
Received on Wednesday, 11 October 2000 14:45:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT