Skip to content

Commit 7a827bf

Browse files
committed
Drop childNodes from treebuilder nodes.
1 parent 167addf commit 7a827bf

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

html5lib/treebuilders/_base.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ def __init__(self, name):
2828
value - The value of the current node (applies to text nodes and
2929
comments
3030
attributes - a dict holding name, value pairs for attributes of the node
31-
childNodes - a list of child nodes of the current node. This must
32-
include all elements but not necessarily other node types
3331
_flags - A list of miscellaneous flags that can be set on the node
3432
"""
3533
self.name = name
3634
self.parent = None
3735
self.value = None
3836
self.attributes = {}
39-
self.childNodes = []
4037
self._flags = []
4138

4239
def __str__(self):
@@ -78,10 +75,7 @@ def reparentChildren(self, newParent):
7875
This is needed so that trees that don't store text as nodes move the
7976
text in the correct way
8077
"""
81-
# XXX - should this method be made more general?
82-
for child in self.childNodes:
83-
newParent.appendChild(child)
84-
self.childNodes = []
78+
raise NotImplementedError
8579

8680
def cloneNode(self):
8781
"""Return a shallow copy of the current node i.e. a node with the same

html5lib/treebuilders/etree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def reparentChildren(self, newParent):
142142
if self._element.text is not None:
143143
newParent._element.text += self._element.text
144144
self._element.text = ""
145-
_base.Node.reparentChildren(self, newParent)
145+
for child in self.childNodes:
146+
newParent.appendChild(child)
147+
self.childNodes = []
146148

147149
class Comment(Element):
148150
def __init__(self, data):

0 commit comments

Comments
 (0)