W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2000

removeAttribute

From: Dieter Köhler <dieter.koehler@ppp.uni-bamberg.de>
Date: Wed, 15 Mar 2000 20:37:23 +0100
Message-ID: <38CFE673.21B6CF8@ppp.uni-bamberg.de>
To: "www-dom@w3.org" <www-dom@w3.org>
In trying to implement the Element.removeAttribute resp.
removeAttributeNS I am a little uncertain what happens with the
attribute node afterwards.  Since it is a remove and not a delete
method it suggests that the attribute is still there.  The problem of
the application is, how to find out its address (in order to entirely
delete it or to insert it somewhere else) since the removeAttribute
method does not return the removed node. So the application has to
detect the Attribute before removal:

MyAttr:= MyElement.getAttributeNode('xyz');
MyElement.removeAttribute('xyz');
deleteOrDoSomethingElse(MyAttr);

But then one could instead use the removeAttributeNode method:

MyAttr:= MyElement.getAttributeNode('xyz');
MyElement.removeAttributeNode(MyAttr);
deleteOrDoSomethingElse(MyAttr);

Conclusion: removeAttribute seems to be for almost every case
replaceable by removeAttributeNode.  So its a superfluous extension of
the DOM unless it gets the removed node as its return value.  Then one
could write:

MyAttr:= MyElement.removeAttribute('xyz');
deleteOrDoSomethingElse(MyAttr);

It's not backward compatible but elegant.

-- 
=====================================================================
 Dieter Koehler, M. A. - dieter.koehler@ppp.uni-bamberg.de
 Mittlere Kaulberg 22, D-96049 Bamberg, +49(0)951-5190726
 "http://www.philo.de/Philosophie-Seiten/": 1000+ Philosophie-Links
 "http://www.philo.de/VirtualLibrary/14.de.htm": Deutsche Philo-Links
 "http://www.philo.de/xml/": Open XML - XML-Komponenten fuer Delphi
=====================================================================
Received on Wednesday, 15 March 2000 14:47:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT