Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7997] MobileWeb : XML - The Titanium.XML.Document method getAttributes gives the message "TypeError: Result of expression elem.getAttributes [undefined] is not a function"

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-15T10:19:58.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsMobileWeb
Labelsqe-mw020912, qe-port
ReporterMichael Pettiford
AssigneeBryan Hughes
Created2012-03-14T11:20:19.000+0000
Updated2012-08-08T16:26:04.000+0000

Description

Steps to reproduce: 1. Create a default mobile web project 2. Replace the code of app.js with the code below

var win = Titanium.UI.createWindow({
			title : "test",
			backgroundColor : 'white'
		});
win.open();

var xmlString = '<a b="c"><d e="f"/></a>';
		var doc = Ti.XML.parseString(xmlString);
		var elem = doc.documentElement.firstChild;
		
		try
		{
			var clone = elem.cloneNode(false);
			
			var elemAttributes = elem.getAttributes();
			var cloneAttributes = clone.getAttributes();
		
			if(elemAttributes.length != cloneAttributes.length)
			{
				throw 'clone length not equal';
			}
			
			else
			{
				alert('clone length equal');
			}
			
			for(var i = 0; i < elemAttributes.length; i++)
			{
				var elemNodeValue = elemAttributes.item(i).getNodeValue();
				var cloneNodeValue = cloneAttributes.item(i).getNodeValue();
				
				if(elemNodeValue != cloneNodeValue)
					throw 'clone node value not equal';
					
				alert(elemNodeValue + '=' + cloneNodeValue);
			}
			
			alert('clone node values equal');
			
			alert('Test Complete.');
		}
		catch(e)
		{
			alert(e.toString());
		}
Actual Result: An error alert is shown with the following error "TypeError: Result of expression 'elem.getAttributes'[undefined] is not a function." Expected Result: No error alert is shown *Expected behavior is shown on iOS and Android*

Comments

  1. Bryan Hughes 2012-03-14

    Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1677
  2. Lokesh Choudhary 2012-08-08

    Tested On: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120807144112 Android 4.0.4 - default ,chrome 18.0 Iphone 4.3.5 - safari mobile Mountain lion(10.8) - chrome 21.0,safari 5.1.4,firefox 14.0.1

JSON Source