Skip to content

Commit edfe801

Browse files
committed
gh-: Ensure that Elements have the ownerDocument attribute
Element uses __slots__, which means that the attribute is not inherited from the superclass. All other slots (except _localName) are set in __init__; not including ownerDocument was an oversight. Note that creating Element directly is not supported; you're supposed to use Document APIs. All supported ways of creating elements do set ownerDocument. However, many projects ignore the documentation.
1 parent a44509e commit edfe801

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Lib/xml/dom/minidom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ class Element(Node):
689689

690690
def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None,
691691
localName=None):
692+
self.ownerDocument = None
692693
self.parentNode = None
693694
self.tagName = self.nodeName = tagName
694695
self.prefix = prefix

0 commit comments

Comments
 (0)