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 16a64ae

Browse files
committed
Add accessor method of Node.appendChild()
But it is not fully implemented.
1 parent 926083b commit 16a64ae

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎w3/python/core/interface.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ def _set_ownerDocument(self, owner_document: Document) -> None:
180180
"""Indirect accessor to set the `ownerDocument` property."""
181181
self._owner_document = owner_document
182182

183+
def _appendChild(self, new_child: Node) -> Node:
184+
if new_child.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
185+
for grand_child_node in new_child.childNodes:
186+
self._appendChild(grand_child_node)
187+
else:
188+
self._check_NO_MODIFICATION_ALLOWED_ERR()
189+
self._check_WRONG_DOCUMENT_ERR(new_child)
190+
self._check_HIERARCHY_REQUEST_ERR(new_child)
191+
# XXX
192+
raise NotImplementedError()
193+
return new_child
194+
183195
def _hasChildNodes(self) -> bool:
184196
return self.childNodes.length > 0
185197

@@ -368,7 +380,7 @@ def appendChild(self, newChild: Node) -> Node:
368380
- WRONG_DOCUMENT_ERR: Raised if `newChild` was created from a different document than the one that created this node.
369381
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
370382
"""
371-
raiseNotImplementedError()
383+
returnself._appendChild(newChild)
372384

373385
def hasChildNodes(self) -> bool:
374386
"""This is a convenience method to allow easy determination of whether a node has any children.

0 commit comments

Comments
(0)

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