Created
June 10, 2011 12:30
-
-
Save scottgonzalez/1018755 to your computer and use it in GitHub Desktop.
clean up extra key from amplify.store <1.0.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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