[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

"Node.textContent"

ram

12/24/2015 6:22:00 PM

The web page at

developer.mozilla.org/en-US/docs/Web/API/Node

contains: »

Node.textContent

Is a DOMString representing the textual content
of an element and all its descendants.

«. Do I think correctly when I think that when this property
represents the textual content /of an element/, I would
expect it to be part of the interface »Element« and not »Node«?

The documentation does not even bother to specify the value
or meaning of this property for a non-element node.

BTW: In the above quotation, they use the Verb »Is«, not
»Returns«.

6 Answers

JJ

12/25/2015 4:50:00 AM

0

On 24 Dec 2015 18:21:51 GMT, Stefan Ram wrote:
> The web page at
>
> developer.mozilla.org/en-US/docs/Web/API/Node
>
> contains: »
>
> Node.textContent
>
> Is a DOMString representing the textual content
> of an element and all its descendants.
>
> «. Do I think correctly when I think that when this property
> represents the textual content /of an element/, I would
> expect it to be part of the interface »Element« and not »Node«?
>
> The documentation does not even bother to specify the value
> or meaning of this property for a non-element node.
>
> BTW: In the above quotation, they use the Verb »Is«, not
> »Returns«.

textContent used to be a member of Element, but it seems that it has changed
since DOM3.

Christoph M. Becker

12/25/2015 10:56:00 AM

0

Stefan Ram wrote:

> The web page at
>
> developer.mozilla.org/en-US/docs/Web/API/Node
>
> contains: »
>
> Node.textContent
>
> Is a DOMString representing the textual content
> of an element and all its descendants.
>
> «. Do I think correctly when I think that when this property
> represents the textual content /of an element/, I would
> expect it to be part of the interface »Element« and not »Node«?
>
> The documentation does not even bother to specify the value
> or meaning of this property for a non-element node.

See the relevant specification:
<http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textC....

--
Christoph M. Becker

Evertjan.

12/25/2015 12:36:00 PM

0

JJ <jj4public@vfemail.net> wrote on 25 Dec 2015 in comp.lang.javascript:

> textContent used to be a member of Element,

Membership fees were overdue?

> but it seems that it has changed since DOM3.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

JR

12/25/2015 2:10:00 PM

0

On 24/12/2015 16:21, Stefan Ram wrote:
> The web page at
>
> developer.mozilla.org/en-US/docs/Web/API/Node
>
> contains: »
>
> Node.textContent

Notice the capital letter "N", which means the Interface Node of the DOM
Levels 3 [1] and 4 [2].

>
> Is a DOMString representing the textual content
> of an element and all its descendants.

interface Node {
// NodeTypes ...
// ...
// attributes ...
// Introduced in DOM Level 3:
attribute DOMString textContent;
// ...
};

>
> «. Do I think correctly when I think that when this property
> represents the textual content /of an element/, I would
> expect it to be part of the interface »Element« and not »Node«?

No, textContent is a readable/writeable attribute of the interface Node.

The DOM presents documents as a hierarchy of Node objects that also
implement other, more specialized interfaces.

Node is an abstract interface and does not exist as node. It is used by
all nodes (Document, DocumentFragment, DocumentType, Element, Text,
ProcessingInstruction, and Comment). [2]


>
> The documentation does not even bother to specify the value
> or meaning of this property for a non-element node.
>
> BTW: In the above quotation, they use the Verb »Is«, not
> »Returns«.
>

MDN is very cool, but it is not a substitute for the W3C Standards and
Drafts [3]. Interestingly, three editors of the W3C DOM4 recommendation
are from Mozilla.

textContent may return null [4].

[1] <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950...
[2] <http://www.w3.org/TR/dom...
[3] <http://www.w3.org/TR/#...
[4] <http://www.w3.org/TR/dom/#dom-node-textc...
--
Joao Rodrigues

Thomas 'PointedEars' Lahn

12/25/2015 3:19:00 PM

0

Stefan Ram wrote:

> The web page at
>
> developer.mozilla.org/en-US/docs/Web/API/Node
>
> contains: »
>
> Node.textContent
>
> Is a DOMString representing the textual content
> of an element and all its descendants.
>
> «. Do I think correctly when I think that when this property
> represents the textual content /of an element/, I would
> expect it to be part of the interface »Element« and not »Node«?

No, because the â??Elementâ? interface extends the â??Nodeâ? interface.

> The documentation does not even bother to specify the value
> or meaning of this property for a non-element node.

MDN is not supposed to nor does it claim to be a substitute for Web
standards. Follow the references.

> BTW: In the above quotation, they use the Verb »Is«, not
> »Returns«.

Which is correct as it is not a method.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

12/25/2015 4:50:00 PM

0

JJ wrote:

> textContent used to be a member of Element,

No, it did not:

<http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745...

> but it seems that it has changed since DOM3.

The â??textContentâ? attribute was only introduced with DOM Level 3 Core,
and it was introduced there on the Node interface:

,-<http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950...
|
| [â?¦]
|
| interface Node {
| [â?¦]
| // Introduced in DOM Level 3:
| attribute DOMString textContent;
| [â?¦]

That has not changed:

,-<http://www.w3.org/TR/2015/REC-dom-20151119...
|
| interface Node : EventTarget {
| [â?¦]
| attribute DOMString? textContent;
| [â?¦]

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.