phonegap/phonegap-android — Issue #282: Cupcake LocalStorage issue. Android.
Author: aogilvie
Created: 2011-10-26 10:07:51+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;
}