Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created June 10, 2011 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottgonzalez/1018755 to your computer and use it in GitHub Desktop.
Save scottgonzalez/1018755 to your computer and use it in GitHub Desktop.
clean up extra key from amplify.store <1.0.0
// Prior to 1.0.0, amplify.store created a key to track all of the values
// that were stored. The 1.0.0 release no longer uses this key and as a
// result, if you ask for all of the values (using amplify.store()) you'll
// get back one extra value.
//
// Simply include this code after you include amplify.store and it will
// remove the extra key. You'll want to include this anywhere that you
// have previously used amplify.store.
(function() {
var types = amplify.store.types;
if ( types.localStorage ) {
localStorage.removeItem( "__amplify__" );
}
if ( types.sessionStorage ) {
sessionStorage.removeItem( "__amplify__" );
}
if ( types.globalStorage ) {
globalStorage[ location.hostname ].removeItem( "__amplify__" );
}
if ( types.userData ) {
var div = document.createElement( "div" );
document.getElementsByTagName( "head" )[ 0 ].appendChild( div );
div.addBehavior( "#default#userdata" );
div.load( "amplify" );
div.removeAttribute( "amplify" );
div.save( "amplify" );
div.parentNode.removeChild( div );
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment