Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29223 > unrolled thread

Re: the interface "Document"

Started byThomas 'PointedEars' Lahn <PointedEars@web.de>
First post2016-01-11 01:22 +0100
Last post2016-01-11 01:22 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: the interface "Document" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-11 01:22 +0100

#29223 — Re: the interface "Document"

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-01-11 01:22 +0100
SubjectRe: the interface "Document"
Message-ID<2202994.V7Pf0K8EyJ@PointedEars.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.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web