Skip to content

Commit 45c051c

Browse files
Merge pull request #21 from js-cookie/void-remove
Drop the Boolean return value of the "remove" method
2 parents 1257445 + bb9234b commit 45c051c

3 files changed

Lines changed: 5 additions & 18 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ Cookies.get(); // => { name: 'value' }
7474
Delete cookie:
7575

7676
```javascript
77-
// Returns true when cookie was successfully deleted, otherwise false
78-
Cookies.remove('name'); // => true
79-
Cookies.remove('nothing'); // => false
77+
Cookies.remove('name');
8078

8179
// Need to use the same path, domain and secure attributes that were used when writing the cookie
8280
Cookies.set('name', 'value', { path: '/' });

‎src/js.cookie.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@
132132
api.defaults = {};
133133

134134
api.remove = function (key, options) {
135-
// Must not alter options, thus extending a fresh object...
136-
api(key, '', extend(options, { expires: -1 }));
137-
return !api(key);
135+
api(key, '', extend(options, {
136+
expires: -1
137+
}));
138138
};
139139

140140
api.withConverter = init;

‎test/tests.js‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ test('defaults', function () {
164164
ok(Cookies.set('c', 'v', { path: '/bar' }).match(/path=\/bar/), 'options argument has precedence');
165165
});
166166

167-
module('removeCookie', lifecycle);
167+
module('remove', lifecycle);
168168

169169
test('deletion', function () {
170170
expect(1);
@@ -173,17 +173,6 @@ test('deletion', function () {
173173
strictEqual(document.cookie, '', 'should delete the cookie');
174174
});
175175

176-
test('when sucessfully deleted', function () {
177-
expect(1);
178-
Cookies.set('c', 'v');
179-
strictEqual(Cookies.remove('c'), true, 'returns true');
180-
});
181-
182-
test('when cookie does not exist', function () {
183-
expect(1);
184-
strictEqual(Cookies.remove('c'), true, 'returns true');
185-
});
186-
187176
test('with options', function () {
188177
expect(1);
189178
var options = { path: '/' };

0 commit comments

Comments
 (0)