Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29223
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: the interface "Document" |
| Date | 2016-01-11 01:22 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2202994.V7Pf0K8EyJ@PointedEars.de> (permalink) |
| References | <Document-20160109200050@ram.dialup.fu-berlin.de> <DOM4-20160110011835@ram.dialup.fu-berlin.de> <subclassof-20160110235909@ram.dialup.fu-berlin.de> |
Stefan Ram wrote: > ram@zedat.fu-berlin.de (Stefan Ram) writes: >>ram@zedat.fu-berlin.de (Stefan Ram) writes: >>>Is their IDL restricted to single inheritance? >>The DOM4-IDL seems to have inherited (no pun intended) >>single inheritance from JavaScript. Nonsense. Instead, the fact that DOM interfaces should be language-neutral makes it a bad idea to specify them using multiple inheritance as that is not supported by all object-oriented programming languages; most notably, not by ECMAScript implementations. > I would like to show in my course that »Document« is a > »subclass« (using a term from the Java world) of »Node«. Don’t. DOM interfaces are *language-neutral*. The proper language-neutral wording is that one interface extends another. > I could do this as follows: > > |< new Document instanceof Node > |> true Where? Not in WebKit/Blink: | > new Document instanceof Node | Uncaught TypeError: Illegal constructor(…) > , but at that point in my course, I have not yet introduced »new«. You should refrain from giving courses until you got the basics yourself. Enough nonsense is being disseminated in this field already, by books, and clueless talks, blog and forum posts. > I could show them this (calls and the dot notation were > already explained): > > |< Object.getPrototypeOf( Document.prototype ).constructor.name > |> "Node" > > , but this would still be too complicated at this point in > the course, It would also be wrong. The implementation of “Document” and “Node” interfaces does _not_ imply the existence of objects referrable with “Document” and “Node”, that those are objects that can be called as constructors, or that they have a “prototype” property. > Sigh, so I am afraid, there is no way to show this that only > uses calls, dot notation, and operators, and is small and > easy as »new Document instanceof Node«? No, there is. It stands to reason that the object referred to by the host-defined “document” property of the global object (the “document” object) would be constructed (internally) using that interface. And so in Blink (Chromium 46): document.constructor.name === "HTMLDocument" document instanceof HTMLDocument === true document instanceof Document === true document instanceof Node === true In order to establish the inheritance hierarchy without that, one only needs to show that the “document” object has properties that are implementations of attributes of different DOM interfaces that are specified to extend each other. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread
Re: the interface "Document" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-11 01:22 +0100
csiph-web