- From: Sylvain Spinelli <sylvain.spinelli@free.fr>
- Date: Thu, 04 Oct 2012 20:52:27 +0200
- To: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>
- CC: "www-dom@w3.org" <www-dom@w3.org>
It's useful when you manipulate DOM trees. For example : - In a previous project I have implemented a xml editor : the DOM source (in any arbitrary schema xml) is traversed and binded with html widgets for editing. In the building editor process I need to keep some properties on each Attr object. - In a new project I work on an algorithm for identifying differences between two DOM trees. I need to get Attr object by its name and set some computed matching scores on it. More generally, I think that getAttr() should be the primary method since the two others are only small syntactic sugar (http://en.wikipedia.org/wiki/Syntactic_sugar) : - getAttribute(n) === getAttr(n).value - hasAttribute(n) === getAttr(n)!=null Le 04/10/2012 18:36, Marat Tanalin | tanalin.com a écrit : > 04.10.2012, 16:21, "Sylvain Spinelli" <sylvain.spinelli@free.fr>: >> Getting Attr object from an Element by its QName or localName + ns is >> really useful. >> Since Attr class no longer inherits from Node, "getAttributeNode" and >> "getAttributeNodeNS" names are misfit. >> >> Perhaps we could have 2 new methods : >> - Attr? getAttr(DOMString name); >> - Attr? getAttrNS(DOMString? namespace, DOMString localName); >> >> WDYT ? > Why someone at all could need to get an attribute as a node/object instead of a string (for the latter, `getAttribute()` works fine)? > > `getAttributeNode()` should probably be just marked as obsolete. >
Received on Thursday, 4 October 2012 18:53:00 UTC