Skip to content

Commit

Permalink
Fixed ie userdata adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
KnisterPeter committed Jun 14, 2011
1 parent 170d340 commit c476bae
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/adapters/ie-userdata.js
Expand Up @@ -2,8 +2,10 @@
* ie userdata adaptor
*
*/
Lawnchair.extend({

Lawnchair.adapter('ie-userdata', {
valid: function () {
return typeof(document.body.addBehavior) != 'undefined';
},
init:function(){
var s = document.createElement('span');
s.style.behavior = 'url(\'#default#userData\')';
Expand All @@ -16,7 +18,7 @@ Lawnchair.extend({

get:function(key, callback){

var obj = this.deserialize(this.storage.getAttribute(key));
var obj = JSON.parse(this.storage.getAttribute(key) || 'null');
if (obj) {
obj.key = key;

Expand All @@ -28,7 +30,7 @@ Lawnchair.extend({
save:function(obj, callback){
var id = obj.key || 'lc' + this.uuid();
delete obj.key;
this.storage.setAttribute(id, this.serialize(obj));
this.storage.setAttribute(id, JSON.stringify(obj));
this.storage.save('lawnchair');
if (callback){
obj.key = id;
Expand All @@ -44,7 +46,7 @@ Lawnchair.extend({
// yo ho yo ho a pirates life for me
for (var i = 0, l = ca.length; i < l; i++) {
v = ca[i];
o = this.deserialize(v.nodeValue);
o = JSON.parse(v.nodeValue || 'null');
if (o) {
o.key = v.nodeName;
yar.push(o);
Expand Down

0 comments on commit c476bae

Please sign in to comment.