- From: Stephen R. Savitzky <steve@rsv.ricoh.com>
- Date: 05 Oct 1999 08:47:06 -0700
- To: www-dom@w3.org
keshlam@us.ibm.com writes: > > If instanceof(Attr) returns true, it'd better be an Attr node, > > or your users will get very confused. It may legitimately be a subclass of Attr. Problems arise, however, if you implement all node types using the same class, something which the Level 1 specification specifically allows. In that case you can use instanceof to test whether a particular interface is supported by a node, but not to test whether a particular node is functioning in the document as a specific node type. The two are NOT INTERCHANGEABLE. > I"m completely undecided as to whether that should be considered a bug or > not. It depends on an assumption about whether or not an API is a > contract guaranteeing that behavior will be supported, or stating how that > behavior behaves if this instance supports it, and I think there are > legitimate design spaces for both. Since the DOM doesn't make a statement > either way, I wouldn't count on instanceof() to distinguish node types, > and I generally advise users to avoid doing so, since there's a good > alternative (nodeType) which _is_ promised to Do The Right Thing. This makes it all the more important to allow implementors to extend the set of node types. Not all languages support intanceof (C being an excellent example). -- Stephen R. Savitzky <steve@rsv.ricoh.com> <http://rsv.ricoh.com/~steve/> Quote of the month: Death is nature's way of telling you to slow down. Chief Software Scientist, Ricoh Silicon Valley, Inc. Calif. Research Center voice: 650.496.5710 front desk: 650.496.5700 fax: 650.854.8740 home: <steve@theStarport.org> URL: http://theStarport.org/people/steve/
Received on Tuesday, 5 October 1999 11:47:44 UTC