Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4704] Android: XML Element.setAttributeNode(attr) causes NPE

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-07-27T09:37:18.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sSprint 2011-30, Release 1.8.0
ComponentsAndroid
Labelsn/a
ReporterBill Dawson
AssigneeBill Dawson
Created2011-07-18T10:15:01.000+0000
Updated2011-08-26T15:12:27.000+0000

Description

Sample failing drillbit code:
var doc = Ti.XML.parseString(this.testSource["nodes.xml"]);
var node = doc.getElementsByTagName("node").item(0);
var attr = doc.createAttribute("newattr");
node.setAttributeNode(attr); // NPE

Comments

  1. Bill Dawson 2011-07-25

    Problem is that, as per the [spec](http://www.w3.org/TR/DOM-Level-2-Core/core.html), setAttributeNode returns null if an attribute with same name doesn't already exist. If it does already exist, it returns the attribute being replaced.
  2. Bill Dawson 2011-07-25

    Pull request ready https://github.com/appcelerator/titanium_mobile/pull/277
  3. Don Thorp 2011-07-27

    Reviewed and tested.
  4. Natalie Huynh 2011-08-26

    Tested Drillbit XML with: version=1.8.0 timestamp=08/26/11 14:21 githash=0e2031e Android Emulator 2.1 and 3.2

JSON Source