Skip to content

Commit be47cde

Browse files
KrinkleFagnerMartinsBrack
authored andcommitted
Invalid cookie value should not be a getter
Closes js-cookiegh-308. Closes gh-309.
1 parent 14557ed commit be47cde

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎jquery.cookie.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
// Write
5858

59-
if (value !== undefined && !$.isFunction(value)) {
59+
if (arguments.length > 1 && !$.isFunction(value)) {
6060
options = $.extend({}, config.defaults, options);
6161

6262
if (typeof options.expires === 'number') {

‎test/tests.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ test('number', function () {
194194
strictEqual($.cookie('c'), '1234', 'should write value');
195195
});
196196

197+
test('null', function () {
198+
expect(1);
199+
$.cookie('c', null);
200+
strictEqual($.cookie('c'), 'null', 'should write value');
201+
});
202+
203+
test('undefined', function () {
204+
expect(1);
205+
$.cookie('c', undefined);
206+
strictEqual($.cookie('c'), 'undefined', 'should write value');
207+
});
208+
197209
test('expires option as days from now', function () {
198210
expect(1);
199211
var sevenDaysFromNow = new Date();

0 commit comments

Comments
 (0)