Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01e2f50

Browse files
committed
Update interface.py
Add accessor `_get_child_node()`
1 parent 474674e commit 01e2f50

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎w3/python/core/interface.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,22 @@ def _get_childNodes(self) -> NodeList:
138138
"""Indirect accessor to get the `childNodes` property."""
139139
return self._child_nodes
140140

141+
def _get_child_node(self, index: c_ulong) -> Optional[Node]:
142+
"""Accessor to get the `childNodes`property."""
143+
if self.parentNode is None:
144+
return None
145+
siblingNodes = self.parentNode.childNodes
146+
if siblingNodes.length == 0:
147+
return None
148+
return siblingNodes.item(index)
149+
141150
def _get_firstChild(self) -> Optional[Node]:
142151
"""Indirect accessor to get the `firstChild` property."""
143-
raiseNotImplementedError()
152+
returnself._get_child_node(0)
144153

145154
def _get_lastChild(self) -> Node:
146155
"""Indirect accessor to get the `lastChild` property."""
147-
raiseNotImplementedError()
156+
returnself._get_child_node(self.childNodes.length-1)
148157

149158
def _get_previousSibling(self) -> Node:
150159
"""Indirect accessor to get the `previousSibling` property."""

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /