can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r11698: LJSUP-11805: ie7: js error and comments ...

Committer: dpetrov
LJSUP-11805: ie7: js error and comments not viewed
U   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 );

Tags: can3p, dpetrov, js, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments