Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6510] iOS : XML - When using the method getElemenetByTagName on an element that doesn't exist, an error should be thrown

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2011-12-12T09:59:25.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelsregression
ReporterMichael Pettiford
AssigneeStephen Tramer
Created2011-12-07T17:29:08.000+0000
Updated2017-03-22T21:10:52.000+0000

Description

Steps to reproduce: 1. Copy the sample code into a new ti mobile project

var win = Ti.UI.createWindow({});
var xmlString = "<benny/>";
var doc = Ti.XML.parseString(xmlString);
var elem = doc.getElementsByTagName("mickey").item(0);

win.open();

2. run the app Expected result: An error should be thrown because the element does not exist Actual result: No error is thrown

Comments

  1. Ivan Skugor 2011-12-08

    I apologize for the interruption, but I'm not so sure that exception should be thrown in this case. If no element is found by some tag name, empty NodeList collection should be returned, so doc.getElementsByTagName("mickey").length would be 0 and doc.getElementsByTagName("mickey").item(0) should return null.
  2. Stephen Tramer 2011-12-12

    This would violate the DOM L2 spec. Please see: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-536297177 Node lists should return 'null', not throw an exception, for an item which is out of bounds.
  3. Lee Morris 2017-03-22

    Closing ticket as "Won't Fix".

JSON Source