gigebyte / cookies

Automatically exported from code.google.com/p/cookies
0 stars 0 forks source link

Code breaks at line 225 when starts up. #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps reproduce the problem?
1. run the code using cookies - setting and reading the cookies.

What is the expected result of the above steps?  What do you see instead?

I see a Type Error being thrown from line 225 - value = JSON.stringify( value );

And the script just halts everything.  As a stop gap measure, I put the code in 
try catch.  

What version of the following are you using?
  jQuery: 1.8
  cookies: 2.20

What browser/version are you using?

safari

What OS/version are you using?

mac os x snow leopard

Do you have any additional information to provide?

No.

Original issue reported on code.google.com by wpoosang...@gmail.com on 18 Feb 2013 at 1:38

GoogleCodeExporter commented 9 years ago
I have had no such fault at any time when using the library, and use Safari 
quite regularly.

Can you tell me about the value you're trying to set to a cookie? Can you 
provide any code?

Thanks,
Jim

Original comment by auldrid...@gmail.com on 18 Feb 2013 at 5:30

GoogleCodeExporter commented 9 years ago
The print out I have is:

value : [object HTMLInputElement]
jquery.cookies.2.2.0.js:232 cookies.set() JSON.stringify error, could
not serialize. erorr: TypeError: Type error

I traced the code but I still do not see yet where did I set an html
element.  But in any case, that error caused the script to halt.  So I
still have to keep the try catch around the code.  Thanks for your
work.

Original comment by wpoosang...@gmail.com on 18 Feb 2013 at 9:16

GoogleCodeExporter commented 9 years ago
I will have to think about this some. You should definitely not be trying to 
set a DOM element to a cookie, and you should attempt to resolve that (as you 
alluded).

It seems to me that I could try to gracefully handle this sort of thing with a 
built in try/catch, but honestly it is an error and it seems proper to cause a 
JS error rather than silent failure. Otherwise a developer could think they 
were setting things into cookies which they actually are not.

I think my best approach would be to leave my code as is, and warn devs in the 
documentation that any value given to the library must be something which is 
capable of serialization, else an error will be raised. If a dev thinks they 
may end up in such a situation and cannot properly account for it in their 
code, they should wrap their code in their own try/catch.

Original comment by auldrid...@gmail.com on 18 Feb 2013 at 9:47

GoogleCodeExporter commented 9 years ago
Just a suggestion, you should mark this as a WONTFIX. Right now it says it's 
new.

Original comment by virtual...@gmail.com on 9 Jul 2014 at 9:13