| 112 | return newChild |
| 113 | |
| 114 | def appendChild(self, node): |
| 115 | if node.nodeType == self.DOCUMENT_FRAGMENT_NODE: |
| 116 | for c in tuple(node.childNodes): |
| 117 | self.appendChild(c) |
| 118 | ### The DOM does not clearly specify what to return in this case |
| 119 | return node |
| 120 | if node.nodeType not in self._child_node_types: |
| 121 | raise xml.dom.HierarchyRequestErr( |
| 122 | "%s cannot be child of %s" % (repr(node), repr(self))) |
| 123 | elif node.nodeType in _nodeTypes_with_children: |
| 124 | _clear_id_cache(self) |
| 125 | if node.parentNode is not None: |
| 126 | node.parentNode.removeChild(node) |
| 127 | _append_child(self, node) |
| 128 | node.nextSibling = None |
| 129 | return node |
| 130 | |
| 131 | def replaceChild(self, newChild, oldChild): |
| 132 | if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: |