Patch for removeAttributeNode

David Faure faure at kde.org
Fri Jun 27 19:56:17 CEST 2003


removeAttributeNode, and anything else that removes an attribute via
NamedAttrMapImpl::removeNamedItem(), is supposed to return the
old attribute node.

The DOMTS test hc_elementremoveattributenode.html shows that the
attribute node that was returned, had a null value.

This fixes it:

--- xml/dom_elementimpl.cpp     24 Jun 2003 21:34:00 -0000      1.170.2.2
+++ xml/dom_elementimpl.cpp     27 Jun 2003 16:49:34 -0000
@@ -647,7 +647,7 @@ Node NamedAttrMapImpl::removeNamedItem (
     if (!a) return Node();

     if (!a->attrImpl())  a->allocateImpl(element);
-    Node r(a->attrImpl());
+    Node r(a->attrImpl()->cloneNode(false));
     removeAttribute(id);
     return r;
 }

(The "false" doesn't matter, it's ignored). AFAICS this doesn't introduce a memleak

Hmm, I see that ElementImpl::removeAttribute() doesn't use that return value, so this
feels like a waste of time, doing it in removeNamedItem. I should rather change
removeNamedItem to return void, and do the cloning in removeAttributeNode, no?

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
Qtella users - stability patches at http://blackie.dk/~dfaure/qtella.html


More information about the Khtml-devel mailing list