Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing $.store twice adds duplicate en/decoders #5

Open
gregmac opened this issue Jul 12, 2012 · 0 comments · May be fixed by #6
Open

Initializing $.store twice adds duplicate en/decoders #5

gregmac opened this issue Jul 12, 2012 · 0 comments · May be fixed by #6

Comments

@gregmac
Copy link

gregmac commented Jul 12, 2012

Running the following code:

s = new $.store(); 
s.set('test', {"a":1}); 
console.log('Get 1', s.get('test')); 
s = new $.store(); 
console.log('Get 2', s.get('test')); 

results in

Get 1  Object
              a: 1
SyntaxError: Unexpected token o

This happens because .encoders and .decoders are part of the prototype, and thus globally modified every time new $.store is called.

This is an issue because I am using this in a single page application, and use it in just one model where it's needed (instead of storing a global reference and only initializing once).

gregmac added a commit to gregmac/jQuery-store that referenced this issue Jul 12, 2012
@gregmac gregmac linked a pull request Jul 12, 2012 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant