View Full Version : Bug in DataView

12 Sep 2011, 3:45 AM
list.indexOf(record) causes "TypeError: 'undefined' is not an object (evaluating 'node.viewIndex)" when record is not found

I believe that causes it bad getNode implementation:

Code for DataView.indexOf:

indexOf: function(node) {
node = this.getNode(node);
if (Ext.isNumber(node.viewIndex)) {file:///System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Resources/inspector/Images/errorIcon.pngsencha-touch-debug.js:22945TypeError: 'undefined' is not an object (evaluating 'node.viewIndex')

return node.viewIndex;
return this.all.indexOf(node);

Code for DataView.getNode:

getNode : function(nodeInfo) {
if (Ext.isString(nodeInfo)) {
return document.getElementById(nodeInfo);
} else if (Ext.isNumber(nodeInfo)) {
return this.all.elements[nodeInfo];
} else if (nodeInfo instanceof Ext.data.Model) {
var idx = this.store.indexOf(nodeInfo);
return this.all.elements[idx];
return nodeInfo;

So, when nodeInfo is type of Model and is not found (idx = -1) getNode returns 'undefined' which causes error when indexOf checks node.viewIndex .