File tree Expand file tree Collapse file tree
packages/graphiql-toolkit/src/storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphiql/toolkit ' : patch
3+ ---
4+
5+ Only remove namespaced items when clearing ` localStorage `
Original file line number Diff line number Diff line change @@ -60,9 +60,18 @@ export class StorageAPI {
6060 } else if ( storage === null ) {
6161 // Passing `null` creates a noop storage
6262 this . storage = null ;
63+ } else if ( typeof window !== 'undefined' ) {
64+ this . storage = window . localStorage ;
65+ // We only want to clear the namespaced items
66+ this . storage . clear = ( ) => {
67+ for ( const key in window . localStorage ) {
68+ if ( key . indexOf ( `${ STORAGE_NAMESPACE } :` ) === 0 ) {
69+ window . localStorage . removeItem ( key ) ;
70+ }
71+ }
72+ } ;
6373 } else {
64- // When passing `undefined` we default to localStorage
65- this . storage = typeof window !== 'undefined' ? window . localStorage : null ;
74+ this . storage = null ;
6675 }
6776 }
6877
You can’t perform that action at this time.
0 commit comments