Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8551] iOS: XML: ownerDocument property is null for created nodes

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-01T22:38:19.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.0.2, Release 2.1.0, Sprint 2012-09 API
ComponentsiOS
Labelsapi, module_xml, qe-testadded
ReporterJeff English
AssigneeVishal Duggal
Created2012-04-05T11:21:18.000+0000
Updated2013-12-10T06:03:26.000+0000

Description

Attempting to access the 'ownerDocument' property of a created node (e.g. createElement, createElementNS) returns null rather than a valid document node. When pulling in other open-source javascript libraries for various projects, some of them rely on the ownerDocument field, especially when creating new documents. To reproduce, add the following code to an application and run:
var doc = Ti.XML.parseString('<?xml version="1.0"?><root><test>data</test></root>');

// The following retrieves the first node. The owner document will be valid and correct
var e1 = doc.firstChild;
var o1 = e1.ownerDocument;

// The following creates a new node. The owner document will be null
var e2 = doc.createElement("test");
var o2 = e2.ownerDocument;

Comments

  1. Vishal Duggal 2012-04-23

    Test code
       
       	var doc = Ti.XML.parseString('<?xml version="1.0"?><root><test>data</test></root>');
       	 
       	// The following retrieves the first node. The owner document will be valid and correct
       	var e1 = doc.firstChild;
       	 
       	// The following creates a new node. The owner document will be null
       	var e2 = doc.createElement("test");
       	
       	if (e1.ownerDocument == e2.ownerDocument)
       	{
       		Ti.API.info("Documents match PASS");	
       	}
       	else
       	{
       		Ti.API.info("Documents mismatch FAIL");
       	}
       
       
  2. Vishal Duggal 2012-04-23

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2049
  3. Natalie Huynh 2012-05-18

    Tested with 2.0.2.v20120517141652 on iPhone 4s 5.1
  4. Shyam Bhadauria 2012-08-01

    Re-opening to edit label
  5. Shameer Jan 2013-12-10

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5039

JSON Source