gigebyte / cookies

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

cookieBind / cookieFill / cookify does not work for input fields having 'id' AND 'name' attributes #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps reproduce the problem?

with this html code :

$('#id_pseudo').cookieBind({hoursToLive:24});
...
<input type="text" name="pseudo" id="id_pseudo">

the input value is correctly saved in the cookie 'pseudo' (from 'name' 
attribute)

but when loading the page, that the wrong cookie is read : id_pseudo (from 'id' 
attribute). So nothing is loaded in the input field.

What version of the following are you using?
  jQuery: 1.4.2
  cookies:2.2.0

What browser/version are you using?
FF 3.6.10

What OS/version are you using?
Ubuntu 10.04

Do you have any additional information to provide?

I found the reason of the bug : the attributes 'name' and 'id' are not read in 
the same order at writing and reading time :

The solution is simple, in the source code, just swap 'id' and 'name' in 
nameAttrs declaration for cookieFill (and only for this function) :

was on line 381 :
var n, getN, nameAttrs = ['name', 'id'], name, $this = $( this ), value;
it should be :
var n, getN, nameAttrs = ['id', 'name'], name, $this = $( this ), value;

Only cookieFill use javascript 'pop' function to get attributes to lookup, that 
read the table from the end.

Original issue reported on code.google.com by elapo...@gmail.com on 1 Dec 2010 at 11:56

GoogleCodeExporter commented 9 years ago
This was reported in Issue #19

Thanks,
Jim

Original comment by auldrid...@gmail.com on 19 Dec 2010 at 11:06