Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion knockout.mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
var findBucket = function(key) {
var bucketKey;
try {
bucketKey = key;//JSON.stringify(key);
bucketKey = validatedBucketKey(key);//JSON.stringify(key);
}
catch (e) {
bucketKey = "$$$";
Expand All @@ -805,6 +805,20 @@
}
return bucket;
};

//make sure the key doesn't step on Object.prototype:
var validatedBucketKey = function(key)
{
if ((typeof key === 'string' || key instanceof String) &&
Object.prototype.hasOwnProperty(key) )
{
return "$$"+ key + "$$";
}
else
{
return key;
}
}

this.save = function (key, value) {
findBucket(key).save(key, value);
Expand Down