[TIMOB-4704] Android: XML Element.setAttributeNode(attr) causes NPE
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-07-27T09:37:18.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | Sprint 2011-30, Release 1.8.0 |
Components | Android |
Labels | n/a |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2011-07-18T10:15:01.000+0000 |
Updated | 2011-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
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.Pull request ready https://github.com/appcelerator/titanium_mobile/pull/277
Reviewed and tested.
Tested Drillbit XML with: version=1.8.0 timestamp=08/26/11 14:21 githash=0e2031e Android Emulator 2.1 and 3.2