Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
encukou committed Dec 16, 2025
commit edfe801e828a5a024a0c3e2d2f3ba40c567ff37e
1 change: 1 addition & 0 deletions Lib/xml/dom/minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ class Element(Node):

def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None,
localName=None):
self.ownerDocument = None
self.parentNode = None
self.tagName = self.nodeName = tagName
self.prefix = prefix
Expand Down