- From: <keshlam@us.ibm.com>
- Date: Mon, 24 Apr 2000 14:43:39 -0400
- To: www-dom@w3.org
> Assuming I have an element 'e' and an attribute 'a' named "A" with value > "old", what is the expected behavior supposed to be in the following case? > e.setAttributeNode(a); > a.setValue("new"); > Attr a2 = e.getAttributeNode("A"); > Is a2's value supposed to equal "new" or "old" "new". e.setAttributeNode(a) associates Attr node a with Element node e. a.setValue("new") modifies that node, discarding its previous contents and replacing them with a single Text node containing the value "new". It does not change the attribute's owningElement. When you issue the last line, you are retrieving a reference to the same Attr node, as modified by the second line. If you don't want that behavior, clone the attribute before adding it, or before modifying it, and alter the copy which has not been associated with the Element. ______________________________________ Joe Kesselman / IBM Research
Received on Monday, 24 April 2000 14:44:15 UTC