Skip to content
Browse files

small fix for key regression bug

  • Loading branch information...
1 parent c0475fb commit fb2bc2d45e3413083e6fb74433c568a36fa0721e @brianleroux brianleroux committed Mar 26, 2010
Showing with 15 additions and 2 deletions.
  1. +11 −0 spec/lawnchair-spec.js
  2. +4 −2 src/adaptors/DOMStorageAdaptor.js
View
11 spec/lawnchair-spec.js
@@ -134,6 +134,17 @@ context('Lawnchair', function(){
start();
});
});
+
+
+ should( 'preserve key in callback after save.', function() {
+ stop();
+ var id = 'donotdie';
+ store.save({key:id, foo:'bar'}, function(o){
+ equals(id, o.key);
+ start();
+ });
+ });
+
// ---
});
View
6 src/adaptors/DOMStorageAdaptor.js
@@ -50,8 +50,10 @@ DOMStorageAdaptor.prototype = {
var id = this.table + '::' + (obj.key || this.uuid());
delete obj.key;
this.storage.setItem(id, this.serialize(obj));
- if (callback)
- callback(obj);
+ if (callback) {
+ obj.key = id.split('::')[1];
+ callback(obj);
+ }
},
get:function(key, callback) {

0 comments on commit fb2bc2d

Please sign in to comment.
Something went wrong with that request. Please try again.