summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-12-06 18:27:48 (GMT)
committerFred Drake <fdrake@acm.org>2001-12-06 18:27:48 (GMT)
commit2998a55f2dd658d15d033272ac88aebfc0dda957 (patch)
treecbf941b754429c1a408bb4a79221322c31751d31 /Lib/xml/dom
parent6b04ffe9e59dc8df46f2d68646ed82cbbef0714c (diff)
downloadcpython-2998a55f2dd658d15d033272ac88aebfc0dda957.zip
cpython-2998a55f2dd658d15d033272ac88aebfc0dda957.tar.gz
cpython-2998a55f2dd658d15d033272ac88aebfc0dda957.tar.bz2
Attribute nodes did not always get their ownerDocument and ownerElement
properly set. This fixes that.
Diffstat (limited to 'Lib/xml/dom')
-rw-r--r--Lib/xml/dom/minidom.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 2e9d866..75ff3c3 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -364,9 +364,10 @@ class NamedNodeMap:
attributes as found in an input document.
"""
- def __init__(self, attrs, attrsNS):
+ def __init__(self, attrs, attrsNS, ownerElement):
self._attrs = attrs
self._attrsNS = attrsNS
+ self._ownerElement = ownerElement
try:
property
@@ -430,6 +431,7 @@ class NamedNodeMap:
if type(value) in _StringTypes:
node = Attr(attname)
node.value = value
+ node.ownerDocument = self._ownerElement.ownerDocument
else:
if not isinstance(value, Attr):
raise TypeError, "value must be a string or Attr object"
@@ -445,6 +447,7 @@ class NamedNodeMap:
old.unlink()
self._attrs[node.name] = node
self._attrsNS[(node.namespaceURI, node.localName)] = node
+ node.ownerElement = self._ownerElement
return old
def setNamedItemNS(self, node):
@@ -518,14 +521,18 @@ class Element(Node):
def setAttribute(self, attname, value):
attr = Attr(attname)
# for performance
- attr.__dict__["value"] = attr.__dict__["nodeValue"] = value
+ d = attr.__dict__
+ d["value"] = d["nodeValue"] = value
+ d["ownerDocument"] = self.ownerDocument
self.setAttributeNode(attr)
def setAttributeNS(self, namespaceURI, qualifiedName, value):
prefix, localname = _nssplit(qualifiedName)
# for performance
attr = Attr(qualifiedName, namespaceURI, localname, prefix)
- attr.__dict__["value"] = attr.__dict__["nodeValue"] = value
+ d = attr.__dict__
+ d["value"] = d["nodeValue"] = value
+ d["ownerDocument"] = self.ownerDocument
self.setAttributeNode(attr)
def getAttributeNode(self, attrname):
@@ -608,7 +615,7 @@ class Element(Node):
writer.write("/>%s"%(newl))
def _get_attributes(self):
- return AttributeList(self._attrs, self._attrsNS)
+ return NamedNodeMap(self._attrs, self._attrsNS, self)
try:
property