Skip to content

Commit 28dcdee

Browse files
gh-151943: Fix the documentation of CDATASection, NodeList and Attr
CDATASection extends Text, as in the DOM Level 1 and Level 2 IDL. NodeList.item() returns None for an index out of range, it does not forbid such index. Attribute nodes are not part of the document tree.
1 parent af7e732 commit 28dcdee

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Doc/library/xml.dom.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,9 @@ objects:
465465

466466
.. method:: NodeList.item(i)
467467

468-
Return the *i*'th item from the sequence, if there is one, or ``None``. The
469-
index *i* is not allowed to be less than zero or greater than or equal to the
470-
length of the sequence.
468+
Return the *i*'th item from the sequence,
469+
or ``None`` if *i* is out of range.
470+
Negative indices are not supported.
471471

472472

473473
.. attribute:: NodeList.length
@@ -831,6 +831,12 @@ Attr Objects
831831

832832
:class:`Attr` inherits from :class:`Node`, so inherits all its attributes.
833833

834+
Attribute nodes are not part of the document tree.
835+
They are contained in the :attr:`~Node.attributes` map of an element,
836+
not in its children,
837+
and their :attr:`~Node.parentNode`, :attr:`~Node.previousSibling`
838+
and :attr:`~Node.nextSibling` are always ``None``.
839+
834840

835841
.. attribute:: Attr.name
836842

@@ -1048,7 +1054,8 @@ enclosed in CDATA marked sections are stored in :class:`CDATASection` objects.
10481054
These two interfaces are identical, but provide different values for the
10491055
:attr:`~Node.nodeType` attribute.
10501056

1051-
These interfaces extend the :class:`CharacterData` interface.
1057+
:class:`Text` extends the :class:`CharacterData` interface,
1058+
and :class:`CDATASection` extends :class:`Text`.
10521059

10531060

10541061
.. attribute:: Text.data

0 commit comments

Comments
 (0)