callback/callback-android — Issue #34: Cupcake LocalStorage issue. Android.
Author: macdonst
Created: 2011-11-25 19:50:04+00:00
State: open

This line -> this.length = length;
from line: 4462 JS version 1.1.0

var CupcakeLocalStorage = function() {
try {

this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
var storage = {};
this.length = 0;
function setLength (length) {
this.length = length;
localStorage.length = length;
}

is being defined on Window !!
you can test this in setLength function by doing;

function setLength (length) {
console.log('Setting length on ' + this );
this.length = length;
localStorage.length = length;
}

The following change could be made to make sure that the this.length is not referring to the Window object.
The line-> localStorage.length = length; <- is unnecessary.

var that = this;
function setLength (length) {
that.length = length;
}