[TIMOB-6510] iOS : XML - When using the method getElemenetByTagName on an element that doesn't exist, an error should be thrown
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-12-12T09:59:25.000+0000 |
Affected Version/s | Release 1.8.0.1 |
Fix Version/s | n/a |
Components | iOS |
Labels | regression |
Reporter | Michael Pettiford |
Assignee | Stephen Tramer |
Created | 2011-12-07T17:29:08.000+0000 |
Updated | 2017-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
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.
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.
Closing ticket as "Won't Fix".