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


Groups > comp.lang.javascript > #29223

Re: the interface "Document"

Path csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: the interface "Document"
Date Mon, 11 Jan 2016 01:22:40 +0100
Organization PointedEars Software (PES)
Lines 75
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>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1452471761 6843 eJwFwYEBwDAEBMCVGjwyTjz2H6F3UD/OMIcbFru1zprlaykeUbscifywKjN4jSLksjUju39ITxJV (11 Jan 2016 00:22:41 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 11 Jan 2016 00:22:41 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNxsERACAIA7CVsFDEcQB1/xH08gnVh/c0pxvvhyRi6nCGna31h8NI3LacFdJoSZfaASopoQMr4KuwrB4nZxQK
Cancel-Lock sha1:p1PBblWYhChcytlP+7/i5PBdq3E=
X-NNTP-Posting-Host eJwNy8EBwCAIA8CVAhKEcZTC/iPY+x+Xi9c2pxuHUycVEa5o6MkrWE1G5gVs7CvdolLS/A/aHwNNEAQ=
Xref csiph.com comp.lang.javascript:29223

Show key headers only | View raw


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


Thread

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

csiph-web