PDA

View Full Version : Ext.data.WebStorageProxy->getRecord Bug in Safari



danielp
9 Jun 2011, 12:19 PM
When using a localStorage Proxy for your Model and you call something like:

myModel.load(1)

if the Model with id is not existend in the local storage yet, you get a Fatal Error in Safari.

My Bugfix (sencha-touch-debug.js) around line 9219:

getRecord: function(id) {

if (this.cache[id] == undefined) {
console.log('storage1', this.getStorageObject().getItem(this.getRecordKey(id)), this.getRecordKey(id), id );

var rawData = Ext.decode(this.getStorageObject().getItem(this.getRecordKey(id))),
data = {},
Model = this.model,
fields = Model.prototype.fields.items,
length = fields.length,
i, field, name, record;
//BUGFIX Start:
// when myModel.load(1) with unknow id
// rawData is null and data[name] = rawData[name]; throw failure on some browsers
if (rawData == null) {
return null;
}
//Bugfix ends//
for (i = 0; i < length; i++) {