[ljcom] r11698: LJSUP-11805: ie7: js error and comments ...
Committer: dpetrov
LJSUP-11805: ie7: js error and comments not viewedU trunk/htdocs/js/jquery/jquery.storage.js
Modified: trunk/htdocs/js/jquery/jquery.storage.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.storage.js 2012-04-12 07:53:35 UTC (rev 11697)
+++ trunk/htdocs/js/jquery/jquery.storage.js 2012-04-12 08:44:09 UTC (rev 11698)
@@ -42,12 +42,19 @@
var storageId = 'jQueryStorageProvider',
storageName = '__jQueryStorage__',
node;
+
function _create() {
node = $( '<link>' ).attr( 'id', storageId ).css( 'display', 'none' ).appendTo( $( 'head' ) ).get(0);
node.addBehavior( '#default#userdata' );
node.load( storageName );
}
+ //LJSUP-11805: IE does not allow special symbols as attribute names
+ function _normalize(name) {
+ return name.replace(/[^0-9a-z_-]/ig, '_');
+ };
+
+
_create();
return {
@@ -58,7 +65,7 @@
* @param {String} val
*/
setItem: function( name, val ) {
- node.setAttribute( name, stringify(val) );
+ node.setAttribute(_normalize(name), stringify(val) );
node.save( storageName );
},
/**
@@ -68,7 +75,7 @@
* @return {Object|String} Item value or null it it does not exist.
*/
getItem: function( name ) {
- return parse(node.getAttribute(name));
+ return parse(node.getAttribute(_normalize(name)));
},
/**
* Remove item from the storage
@@ -137,7 +144,7 @@
}
}
- //We shoud never reach this point.
+ //We should never reach this point.
}();
} ) ( jQuery );
