|
23 | 23 | var i = 0; |
24 | 24 | var result = {}; |
25 | 25 | for (; i < arguments.length; i++) { |
26 | | - var options = arguments[ i ]; |
27 | | - for (var key in options) { |
28 | | - result[key] = options[key]; |
| 26 | + var attributes = arguments[ i ]; |
| 27 | + for (var key in attributes) { |
| 28 | + result[key] = attributes[key]; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | return result; |
32 | 32 | } |
33 | 33 |
|
34 | 34 | function init (converter) { |
35 | | - function api (key, value, options) { |
| 35 | + function api (key, value, attributes) { |
36 | 36 | var result; |
37 | 37 |
|
38 | 38 | // Write |
39 | 39 |
|
40 | 40 | if (arguments.length > 1) { |
41 | | - options = extend({ |
| 41 | + attributes = extend({ |
42 | 42 | path: '/' |
43 | | - }, api.defaults, options); |
| 43 | + }, api.defaults, attributes); |
44 | 44 |
|
45 | | - if (typeof options.expires === 'number') { |
| 45 | + if (typeof attributes.expires === 'number') { |
46 | 46 | var expires = new Date(); |
47 | | - expires.setMilliseconds(expires.getMilliseconds() + options.expires * 864e+5); |
48 | | - options.expires = expires; |
| 47 | + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); |
| 48 | + attributes.expires = expires; |
49 | 49 | } |
50 | 50 |
|
51 | 51 | try { |
|
64 | 64 |
|
65 | 65 | return (document.cookie = [ |
66 | 66 | key, '=', value, |
67 | | - options.expires && '; expires=' + options.expires.toUTCString(), // use expires attribute, max-age is not supported by IE |
68 | | - options.path && '; path=' + options.path, |
69 | | - options.domain && '; domain=' + options.domain, |
70 | | - options.secure && '; secure' |
| 67 | + attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE |
| 68 | + attributes.path && '; path=' + attributes.path, |
| 69 | + attributes.domain && '; domain=' + attributes.domain, |
| 70 | + attributes.secure && '; secure' |
71 | 71 | ].join('')); |
72 | 72 | } |
73 | 73 |
|
|
122 | 122 | }; |
123 | 123 | api.defaults = {}; |
124 | 124 |
|
125 | | - api.remove = function (key, options) { |
126 | | - api(key, '', extend(options, { |
| 125 | + api.remove = function (key, attributes) { |
| 126 | + api(key, '', extend(attributes, { |
127 | 127 | expires: -1 |
128 | 128 | })); |
129 | 129 | }; |
|
0 commit comments